Bug 26572 - Invalid local class definition not diagnosed
Summary: Invalid local class definition not diagnosed
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, monitored
Depends on:
Blocks:
 
Reported: 2006-03-06 03:09 UTC by Volker Reichelt
Modified: 2013-05-24 10:09 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.2.3, 3.3.2, 3.3.3, 3.4.0, 4.0.0
Last reconfirmed: 2006-09-03 21:39:35


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2006-03-06 03:09:29 UTC
The following invalid code snippet is accepted since at least GCC 2.95.3:

==================================
template<int> void foo()
{
  struct A;
  struct B : A {};
}

template void foo<0>();
==================================

As A is incomplete, the definition of the local class B should trigger
an error. This could already be diagnosed during definition of the
template function, but is not even diagnosed at instantiation time.

It is only diagnosed (at instantiation time) when B is used inside
the function (for example in a variable declaration "B b;").
Comment 1 Andrew Pinski 2006-03-06 13:06:50 UTC
Confirmed.
Comment 2 Paolo Carlini 2013-05-24 09:18:30 UTC
This is fixed for 4.8.0. I'm adding the testcase and closing the PR.
Comment 3 Paolo Carlini 2013-05-24 10:09:01 UTC
Done.