This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/36941] gcc does not reject invalid cast


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36941

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2017-07-25
                 CC|                            |egallager at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #7 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Chris Lattner from comment #0)
> GCC accepts:
> extern struct S x;
> void foo() { (void)x; }
> 
> But correctly rejects:
> 
> extern struct S x;
> void foo() { x; }
> 

Confirmed. Note that clang diagnoses the first one like this:

$ /sw/opt/llvm-3.1/bin/clang-3.1 -c 36941.c
36941.c:2:20: error: incomplete type 'struct S' where a complete type is
required
void foo() { (void)x; }
                   ^
36941.c:1:15: note: forward declaration of 'struct S'
extern struct S x;
              ^

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]