* [Bug c++/27347] [4.0/4.1/4.2 Regression] static array member specialization failure
2006-04-28 10:15 [Bug c++/27347] New: static array member specialization failure maxim dot yegorushkin at gmail dot com
@ 2006-04-28 13:33 ` rguenth at gcc dot gnu dot org
2006-04-29 3:35 ` pinskia at gcc dot gnu dot org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-04-28 13:33 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rguenth at gcc dot gnu dot org 2006-04-28 13:33 -------
Confirmed. Regression with the new C++ parser.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |rejects-valid
Known to fail| |3.4.6 4.0.3 4.1.0 4.2.0
Known to work| |3.3.6
Last reconfirmed|0000-00-00 00:00:00 |2006-04-28 13:33:30
date| |
Summary|static array member |[4.0/4.1/4.2 Regression]
|specialization failure |static array member
| |specialization failure
Target Milestone|--- |4.0.4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27347
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/27347] [4.0/4.1/4.2 Regression] static array member specialization failure
2006-04-28 10:15 [Bug c++/27347] New: static array member specialization failure maxim dot yegorushkin at gmail dot com
2006-04-28 13:33 ` [Bug c++/27347] [4.0/4.1/4.2 Regression] " rguenth at gcc dot gnu dot org
@ 2006-04-29 3:35 ` pinskia at gcc dot gnu dot org
2006-06-04 18:39 ` mmitchel at gcc dot gnu dot org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-04-29 3:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2006-04-29 03:35 -------
The problem I think is the non specialization is getting in the way in that:
template<class T> char const type_name<T>::name[] = "";
is recording the size as 1.
Another testcase with a slightly different error:
emplate<class T> struct type_name { static int const name[]; };
template<class T> int const type_name<T>::name[] = {0};
template<> int const type_name<int>::name[] = {0, 1, 2, 3};
int f(void)
{
return type_name<int>::name[2];
}
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu dot
| |org
Known to fail|3.4.6 4.0.3 4.1.0 4.2.0 |3.4.6 4.0.3 4.1.0 4.2.0
| |3.4.0
Last reconfirmed|2006-04-28 13:33:30 |2006-04-29 03:35:43
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27347
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/27347] [4.0/4.1/4.2 Regression] static array member specialization failure
2006-04-28 10:15 [Bug c++/27347] New: static array member specialization failure maxim dot yegorushkin at gmail dot com
2006-04-28 13:33 ` [Bug c++/27347] [4.0/4.1/4.2 Regression] " rguenth at gcc dot gnu dot org
2006-04-29 3:35 ` pinskia at gcc dot gnu dot org
@ 2006-06-04 18:39 ` mmitchel at gcc dot gnu dot org
2006-06-14 22:17 ` mmitchel at gcc dot gnu dot org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-06-04 18:39 UTC (permalink / raw)
To: gcc-bugs
--
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P1
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27347
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/27347] [4.0/4.1/4.2 Regression] static array member specialization failure
2006-04-28 10:15 [Bug c++/27347] New: static array member specialization failure maxim dot yegorushkin at gmail dot com
` (2 preceding siblings ...)
2006-06-04 18:39 ` mmitchel at gcc dot gnu dot org
@ 2006-06-14 22:17 ` mmitchel at gcc dot gnu dot org
2006-06-14 23:47 ` mmitchel at gcc dot gnu dot org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-06-14 22:17 UTC (permalink / raw)
To: gcc-bugs
--
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |mark at codesourcery dot com
|dot org |
Status|NEW |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27347
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/27347] [4.0/4.1/4.2 Regression] static array member specialization failure
2006-04-28 10:15 [Bug c++/27347] New: static array member specialization failure maxim dot yegorushkin at gmail dot com
` (3 preceding siblings ...)
2006-06-14 22:17 ` mmitchel at gcc dot gnu dot org
@ 2006-06-14 23:47 ` mmitchel at gcc dot gnu dot org
2006-06-15 1:32 ` mmitchel at gcc dot gnu dot org
2006-06-15 2:00 ` mmitchel at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-06-14 23:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from mmitchel at gcc dot gnu dot org 2006-06-14 22:17 -------
I'm not convinced this is a bug in G++.
If the first line were:
template<class T> struct type_name { static char const name[1]; };
then there would be no question that the specialization was invalid. Since the
type of an array variable is indeed determined by its initializer, I don't see
any different between that case and the case in the test case.
I've sent mail to EDG to clarify.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27347
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/27347] [4.0/4.1/4.2 Regression] static array member specialization failure
2006-04-28 10:15 [Bug c++/27347] New: static array member specialization failure maxim dot yegorushkin at gmail dot com
` (4 preceding siblings ...)
2006-06-14 23:47 ` mmitchel at gcc dot gnu dot org
@ 2006-06-15 1:32 ` mmitchel at gcc dot gnu dot org
2006-06-15 2:00 ` mmitchel at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-06-15 1:32 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from mmitchel at gcc dot gnu dot org 2006-06-15 00:27 -------
John Spicer and I discussed this issue, but I don't think we've got a clear
resolution. John believes the example is valid.
However, I asked:
=====
template <int> void g();
template <typename T>
struct S {
static int i[];
void f();
};
template <typename T>
int S<T>::i[] = { 1 };
template <typename T>
void S<T>::f() {
g<sizeof (i) / sizeof (int)>();
}
template <typename T>
int S<int>::i[] = { 1, 2 };
Which g is called from S<int>::f()?
If the program is valid, then surely one would expect g<2> to be called.
If the program is valid, does S<T>::i have a non-dependent type in
S<T>::f? If so, is it incomplete, or is it int[1]? (Here, int[1] would
be surprising, since S<int>::i actually has type int[2].)
If the program is invalid, why?
=====
John says that this is core issue #408. I'm not sure that's really the same
issue, but it's related.
The problem I see is that if S<T>::i has a non-dependent type, it must be
either int[1] or int[]. In the former case, the specialization is invalid. In
the latter case, S<T>::f is invalid since it applies sizeof to an incomplete
type.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27347
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/27347] [4.0/4.1/4.2 Regression] static array member specialization failure
2006-04-28 10:15 [Bug c++/27347] New: static array member specialization failure maxim dot yegorushkin at gmail dot com
` (5 preceding siblings ...)
2006-06-15 1:32 ` mmitchel at gcc dot gnu dot org
@ 2006-06-15 2:00 ` mmitchel at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-06-15 2:00 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from mmitchel at gcc dot gnu dot org 2006-06-15 01:51 -------
John and I talked about this a bit more, and he's going to update the core
issue.
To me, there are only a few options here:
1. S<T>::i has non-dependent type "int[]".
In that case, the sizeof expression is an error.
2. S<T>::i has non-dependent type "int[1]".
In that case, the explicit specialization is an error.
3. S<T>::i has dependent type.
But, why should it? It doesn't use any template parameters.
I like option #2 best. If the in-class declaration for the code in the
original report were "static char const name[1]" then everyone would agree the
specialization is invalid. Why should it make a difference whether the size of
the array is explicitly specified or implied by the initializer? That
distinction doesn't matter anywhere else in the language.
My second choice is option #1.
I'm going to close this PR as invalid. I don't think there's clear support for
this code in the standard.
--
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27347
^ permalink raw reply [flat|nested] 8+ messages in thread