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]

Re: spurious warnings when outputing an enum to an ostream ?


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


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