This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: bug in template function specialization
> From: Alexandre Oliva <oliva@dcc.unicamp.br>
> Date: 08 Jun 1998 02:16:00 -0300
>
> There's no such thing as partial specialization of template
> functions. You can only overload or fully specialize template
> functions.
>
> > #include <stdlib.h>
> > template<class T> inline bool isarray () { return false; }
>
> > template<class T, size_t n> inline bool isarray<T[n]> ()
> > { return true; }
Sorry, I guess I created invalid code when trying to construct a
simple bug report. However, I still believe there is a problem with
template specialization in egcs.
I have appended a simple program that I think demonstrates the
problem. When I compile this program with gcc2 (the only other C++
compiler I have access to), I get:
char: 0
char[10]: 1
Yet when I use the latest egcs I just downloaded [gcc version
egcs-2.91.37 19980608 (gcc2 ss-980502 experimental)], I get this
output:
char: 0
char[10]: 0
As far as I can tell from reading Stroustrup, the bug is in egcs
rather than gcc2.
Thanks,
David
#include <stdio.h>
template<class T>
struct isarray {
enum {value = 0};
};
template<class T, size_t n>
struct isarray<T[n]> {
enum {value = 1};
};
#define TEST(type) printf ("%s: %d\n", #type, isarray<type>::value);
int
main ()
{
TEST (char);
TEST (char[10]);
}