This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/70820] GCC incorrectly accepts code that accesses nested names in an incomplete type
- From: "fdrocha at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 28 Apr 2016 14:03:20 +0000
- Subject: [Bug c++/70820] GCC incorrectly accepts code that accesses nested names in an incomplete type
- Auto-submitted: auto-generated
- References: <bug-70820-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70820
--- Comment #5 from Fabio Rocha <fdrocha at gmail dot com> ---
(In reply to Jonathan Wakely from comment #4)
> (In reply to Fabio Rocha from comment #3)
> > Still, it feels pretty strange that uncommenting the "First Assert" is what
> > makes the code incorrect...
>
> That's not strange at all, the assertion requires the value of the static
> data member, so it causes it to be instantiated, while the type is
> incomplete.
>
> Without that assertion the static data member is not instantiated until the
> definition of ::k, after the types are complete.
That makes sense, it's pretty nice that it works out like this.
For what it's worth, clang rejects the code, but I am convinced gcc is in the
right.