This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Template type bug


  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
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;
}

Attachment: try_template.ii
Description: Binary data

Attachment: try_template.s
Description: Binary data

Attachment: g++-output.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]