Bug 37736 - Problem with designated initializer and template
Summary: Problem with designated initializer and template
Status: RESOLVED DUPLICATE of bug 57041
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: monitored, rejects-valid
Depends on:
Blocks:
 
Reported: 2008-10-05 06:48 UTC by Simon Martin
Modified: 2013-05-14 15:53 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-03-28 20:14:28


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Martin 2008-10-05 06:48:52 UTC
Opened from comment 4 in PR29727.

The following valid snipped is rejected with the current mainline

===
template<int> struct A
{
  struct S { int X; };
  static S a;
};

template<int N> typename A<N>::S A<N>::a = { X : 1 };

void foo()
{
  A<0>::a;
}
===

because 'X' is not found in the designated initializer:

[...]
  pr29727_valid.C:18: error: 'Y' was not declared in this scope
  pr29727_valid.C:18: error: 'B<0>::S' has no non-static data member named '<declaration error>'


We get the same with 4.0.1, 4.2.1 and the 4.3 branch. I don't have any earlier version to check, so I don't know if this is a regression or not.

With a non template class, the code is accepted.
Comment 1 Volker Reichelt 2009-03-28 20:14:28 UTC
Confirmed (also by Paolo in PR29727).
This is rejected since at least GCC 2.95.3.
Comment 2 Paolo Carlini 2013-05-14 15:53:30 UTC
Another Dup.

*** This bug has been marked as a duplicate of bug 57041 ***