[Bug c++/20172] New: member function template declaration not instantiated during the instantiation of the enclosing class template
SWElef at post dot sk
gcc-bugzilla@gcc.gnu.org
Wed Feb 23 20:24:00 GMT 2005
gcc accepts the following ill-formed code (tested with gcc3.4.2 (mingw)
and various cygwin versions (from 3.3.1 to 3.4.3 and an experimental
snapshot 4.0.0-20050130) ):
template <typename T>
struct foo{
template <T t>
static void bar() { }
};
template <typename T>
foo<T> tester(T) { return foo<T>(); }
int main(){
tester(1.2);
return 0;
}
std:14.7.1/1 says
... The implicit instantiation of a class template specialization causes the
implicit instantiation of the declarations, but not of the definitions or
default arguments, of the class member functions, member classes, static
data members and _member_templates_; ...
Thus, the implicit instantiation of struct foo<double> causes the
instantiation of declaration
template <double t> void foo<double>::bar();
which is ill-formed and should be diagnosed.
Remark 1:
The signature of bar is unimportant, it just has to be a function.
If one declares a nested "template <T t> struct S;" gcc correctly
complains when instantiating foo<double>.
Remark 2:
Shorter testcase consists of a declaration of the template foo and an
explicit instantiation of foo<double>, but the wording for implicit
instantiation is much cleaner in this case so I decided to use it.
Regards,
Vladimir Marko
--
Summary: member function template declaration not instantiated
during the instantiation of the enclosing class template
Product: gcc
Version: 3.4.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: SWElef at post dot sk
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20172
More information about the Gcc-bugs
mailing list