This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Is this template problem in ecgs?
- To: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Subject: Re: Is this template problem in ecgs?
- From: Nicholas Lee <nlee011 at math dot auckland dot ac dot nz>
- Date: Wed, 24 Jun 1998 23:14:49 +1200 (NZST)
- cc: egcs at cygnus dot com
On 24 Jun 1998, Alexandre Oliva wrote:
> Nicholas Lee <nlee011@math.auckland.ac.nz> writes:
>
> > template<typename T>
> > inline T& min(const T& x, const T& y) { return (x<y)? x:y; }
>
> Not a template problem, actually. It would also compile if you
> replaced `template<typename T>' with `typedef int T;'. It seems that
> gcc disregards CV-qualification if the return value is a ?:
> expression, but I haven't investigated the problem very much.
What is the correct behaviour?
I would assume since x and y are declared as const T&, that the compiler
should issue a warning that there was a attempt to discard constness without
a const_cast.
--
"I reserve the right to contradict myself."
Nicholas Lee (Li Peng Ming) n.lee with math.auckland.ac in nz
Auckland University, New Zealand