Bug 19538 - [DR 407] Bogus diagnostic for typedef name in elaborated type specifier
Summary: [DR 407] Bogus diagnostic for typedef name in elaborated type specifier
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic, rejects-valid
Depends on:
Blocks:
 
Reported: 2005-01-20 01:51 UTC by Matt Austern
Modified: 2024-02-06 13:26 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2024-02-06 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Austern 2005-01-20 01:51:48 UTC
Consider the following code sample:

struct A { };
typedef struct A A;
struct A a;                     // [1]

struct wrapper {
  struct B { };
  typedef struct B B;
  struct B b;                   // [2]
};

Mainline gives an error for line [2], but not for line [1].  My reading of the standard is that there 
shouldn't be any difference.  In both cases we're using an elaborated type specifier with a name that 
resolves to a typedef-name.  A program that does that is ill formed, so the compiler is required to 
admit a diagnostic.  We're doing that for line [2], but we're failing to do it for line [1].

Relevant passages in the standard: 3.4.4/2, 7.1.3/4, 7.1.5.3/2.
Comment 1 Andrew Pinski 2005-01-20 01:56:59 UTC
Confirmed.  [2] was PR 11036 by the way.
Comment 2 Matt Austern 2005-01-24 18:06:08 UTC
I've raised this issue on the C++ standardization committee's core language reflector.  I now find it a 
little less clear than I did before.  This is closely related to open issue 407.  See http://www.open-
std.org/jtc1/sc22/wg21/docs/cwg_active.html#407
Comment 3 Jonathan Wakely 2011-05-05 00:56:11 UTC
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#407 is no longer open, I think [2] should be accepted
Comment 4 Jonathan Wakely 2020-07-08 15:50:14 UTC
Un-suspending, and changing from accepts-invalid to rejects-valid.

Both [1] and [2] are valid now and should be accepted.
Comment 5 Eric Gallager 2023-10-29 16:23:12 UTC
(In reply to Jonathan Wakely from comment #4)
> Un-suspending, and changing from accepts-invalid to rejects-valid.
> 
> Both [1] and [2] are valid now and should be accepted.

Still a diagnostic issue even it's now rejects-valid instead of accepts-valid, IMO.