operator<< warning in 970910

Hugh W. Holbrook holbrook@CS.Stanford.EDU
Mon Sep 15 02:28:00 GMT 1997


I get the following unexpected warning when trying to compile the
program below with -Wall on linux.

  enum.C: In function `int doit()':
  enum.C:22: warning: passing `E' chooses `int' over `unsigned int'
  enum.C:22: warning:   in call to `operator <<'

Passing an enum constant does not produce the warning, passing the
stack variable does.

-Hugh

Hugh Holbrook                           holbrook@dsg.stanford.edu.nospam
Distributed Systems Group
Stanford University
----------------------------------------------------------------
/***
  This produces the following warning with 
  [Fridge] ~ $ c++ --version
  egcs-2.90.06 970907 (gcc2-970802 experimental)
  [Fridge] ~ $ c++ -c -Wall enum.C
  enum.C: In function `int doit()':
  enum.C:22: warning: passing `E' chooses `int' over `unsigned int'
  enum.C:22: warning:   in call to `operator <<'
***/
#include <iostream.h>

enum E {
    E1,
    E2
};

ostream& operator<<(ostream&, const E&);

int
doit() {
    E e = E1;
    cout << e;
    cout << E1;
    return 0;
}





More information about the Gcc-bugs mailing list