GCC 2.95.2, Next 3.3; explicit specialization loses default
James McKelvey
mckelvey@fafnir.com
Tue Jan 11 21:05:00 GMT 2000
GCC 2.95.2
Next Cube running NextSTEP 4.2, 3.3 Developer
Explicit specialization seems to forget that second argument to constructor
has a default value.
Test case:
class A
{
public:
template <class T>
A(T x, bool y = false);
};
template <class T> A::
A(T, bool)
{
}
template <> A::
A(char, bool)
{
}
int main(void)
{
int b;
char c;
A x(b); // OK
A y(c); // Fails
A z(c, false); // OK
return 0;
}
g++ -DNO_NAMESPACE -D__USE_GNU -DNeXT -g -pipe -ansi -pedantic
-pedantic-errors -fsjlj-exceptions -fno-keep-static-consts -fshort-enums
-fstrict-aliasing -ffloat-store -fno-common -ffor-scope -Wsign-promo
-ftemplate-depth-30 -fverbose-asm -fimplicit-templates
-fno-external-templates -fno-repo -Wall -W -Wbad-function-cast
-Wpointer-arith -Wcast-qual -Wconversion -Wstrict-prototypes
-Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wwrite-strings
-Winline -Wtraditional -Wno-long-long -o x x.cc
x.cc: In function `int main()':
x.cc:31: no matching function for call to `A::A (char &)'
x.cc:21: candidates are: A::A<char>(char, bool)
x.cc:8: A::A(const A &)
x.cc:32: warning: unused variable `class A z'
x.cc:31: warning: unused variable `class A y'
x.cc:30: warning: unused variable `class A x'
gmake: *** [x] Error 1
---
Where diesel guitars from faraway bars, blast out the
best songs from our holy wars. Coyote carnival catches
on fire, all the cops in the world pick us up on radar.
Jim McKelvey mckelvey@fafnir.com
More information about the Gcc-bugs
mailing list