This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: spurious warnings when outputing an enum to an ostream ?
- To: egcs-bugs at cygnus dot com
- Subject: Re: spurious warnings when outputing an enum to an ostream ?
- From: Jason Merrill <jason at yorick dot cygnus dot com>
- Date: 02 Sep 1997 13:36:09 -0700
- Distribution: cygnus
- Newsgroups: cygnus.egcs.bugs
- Organization: Cygnus Solutions, Sunnyvale, CA
- References: <wjxafhywcw7.fsf.cygnus.egcs.bugs@coelacanthe.irisa.fr>
- Xref: cygnus.com cygnus.egcs.bugs:167
>>>>> 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