This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/27347] [4.0/4.1/4.2 Regression] static array member specialization failure
- From: "mmitchel at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 15 Jun 2006 00:27:05 -0000
- Subject: [Bug c++/27347] [4.0/4.1/4.2 Regression] static array member specialization failure
- References: <bug-27347-10484@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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