spurious warnings when outputing an enum to an ostream ?

Jason Merrill jason@yorick.cygnus.com
Tue Sep 2 13:36:00 GMT 1997


>>>>> Laurent Bonnaud <bonnaud@irisa.fr> writes:

> egcs gives warnings for the following code :

> #include <iostream.h>

> enum A {a1,a2};

> ostream& operator<<(ostream& s, const A& a)
> {
>   s<<(int)a;
>   return s;
> }

> int main()
> {
>   A a=a1;
>   cout<<a<<endl;
> }

> % g++ e.cc -Wall
> e.cc: In function `int main()':
> e.cc:14: warning: `A' promotes to `int', not `unsigned int'
> e.cc:14: warning:   in call to `operator <<'

Yes, looks like the warning doesn't belong in joust, but perhaps tourney,
so we only warn about preferring the winning function.  We don't care about
comparisons between two losing functions.  I'll get to this before too
long, unless someone beats me to it.

Jason



More information about the Gcc-bugs mailing list