This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/36941] gcc does not reject invalid cast
- From: "egallager at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 25 Apr 2018 13:02:22 +0000
- Subject: [Bug c/36941] gcc does not reject invalid cast
- Auto-submitted: auto-generated
- References: <bug-36941-4@http.gcc.gnu.org/bugzilla/>
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.