Bug 25503 - g++ accepts invalid typedef in template code
Summary: g++ accepts invalid typedef in template code
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.8.0
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2005-12-20 12:25 UTC by Dirk Bonekaemper
Modified: 2013-05-24 10:08 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.8.0, 4.9.0
Known to fail: 2.95.3, 3.0.4, 3.3.3, 3.4.0, 4.0.0, 4.1.0
Last reconfirmed: 2005-12-20 16:03:30


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Bonekaemper 2005-12-20 12:25:12 UTC
 
Comment 1 Dirk Bonekaemper 2005-12-20 12:28:11 UTC
(Sorry, pressed return to early...)

g++ accepts the following code, which contains a typedef that's supposed to act as a static assert. 
-------------------------------------------------------------------------------
template<int N>
struct Test
{
    Test()
    {
        typedef struct StaticAssert {unsigned condition : (N); } XXX;
    }
};

int
main()
{
    Test<0> T;
}
-------------------------------------------------------------------------------
Comment 2 Wolfgang Bangerth 2005-12-20 16:03:30 UTC
Confirmed. The typedef is only rejected if it is actually used to define
a variable.

W.
Comment 3 Paolo Carlini 2013-05-24 09:42:26 UTC
Also fixed for 4.8.0. I'm adding the test and closing the PR.
Comment 4 Paolo Carlini 2013-05-24 10:08:28 UTC
Done.