Unnecessary warning

llewelly@198.dsl.xmission.com llewelly@198.dsl.xmission.com
Mon Jan 3 11:42:00 GMT 2000

On Mon, 3 Jan 2000, Kip Macy wrote:

> It depends on how you define the desired behaviour of a warning. My
> desired behaviour is to inform me of things in the code that need to be
> fixed, and once fixed the message will go away. However, this example is
> not something one can change without breaking the code - thus, by my
> definition, it is a bug.
> 					-Kip

Try this:
  using std::cout;
int main()
    unsigned int foo;
    foo = 4294967295U; //Use a 'u' or 'U" to indicate an unsigned constant.
    cout << foo << endl;

No warnings. The 'U' (or 'u') is the standard way to mark a constant as
  unsigned. An integer literal without such a suffix is of type 'int'.
  More complicated uses of integer literals whose values are outside the
  range of int can give unexpected results.

by the way:

  'l' or 'L' == long int
  'ul','UL','lu',etc == unsigned long int
  'LL' == long long (this is a gcc extension)

> On Mon, 3 Jan 2000 Martin.Niklasson@nokia.com wrote:
> > Dear Sirs
> > 
> > I am not sure whether you consider this a bug or a
> > feature, but it annoys me a little. If you enter the
> > following C++ lines in a program:
> > 
> >   unsigned int foo;
> >   foo = 4294967295; //Or any constant larger than 2^31
> >   cout << foo << endl;    
> > 
> > then g++ warns about the constant being
> > "so large that it is unsigned".
> > 

More information about the Gcc-bugs mailing list