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
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid, diagnostic
                 CC|                            |joseph at codesourcery dot com

--- Comment #8 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Eric Gallager from comment #7)
> (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;
>               ^

Same thing with a newer version of clang (5.0). Assuming that since clang still
rejects this that this is an accepts-invalid for gcc.

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