Template type bug

Etienne Grossmann etienne@tyzx.com
Tue Jul 1 16:14:00 GMT 2008


  Hello again,

a little addition to my previous post: In a non-main c++ file (say
A.cpp), I write the code

     template <int> int max (int x, int y); // OK
     template <double> double max (double x, double y); // Fails

in order to instantiate the template, so that the function "double
max(double,double)" be in the object file A.o.
With "int", this works, but this fails with "double" and this is why I
sent the bug report.

  I can also instantiate the templates by putting in A.cpp a function

  void instantiateMaxFunctions ()
  {

}


On Mon, Jun 30, 2008 at 9:41 PM, Etienne Grossmann <etienne@tyzx.com> wrote:
>  Hello,
>
> I do not have a login to submit a bug via bugzilla, so I use the
> second method in http://gcc.gnu.org/bugs.html#where and attach all the
> required info.
>
> In short, compiling w/ g++-4.3
> ==================================================
> template <class Comparable> Comparable max (Comparable x, Comparable y)
> {
>  return x >= y ? x : y;
> }
>
> template <int> int max (int x, int y); // OK
> template <double> double max (double x, double y); // Fails
>
> int main ()  { return 0;}
> ===================================================
> results in "error: 'double' is not a valid type for a template
> constant parameter", which I believe is inappropriate here.
>
>  Is this a known bug? I found similar bugs:
> http://gcc.gnu.org/ml/gcc-patches/2006-06/msg01159.html
> http://gcc.gnu.org/ml/gcc-bugs/2007-12/msg02358.html, but they don't
> quite match.
>
> Another question: in http://gcc.gnu.org/bugs.html#known, there are
> many references, e.g. "see [14.6]", but there is no
>  bibliography. What is the refered document? (If it is an online
> document, the page bugs.html could contain links, thus avoiding silly
> questions like this one)
>
>  Thanking you for making g++ available in the first place,
>
>  Etienne
>



More information about the Gcc-bugs mailing list