Doubtful warning

Martin v. Loewis
Tue Jan 26 02:28:00 GMT 1999

>   A<4294967295> v;
> The template parameter *is* unsigned - so why do I get this warning?

That doesn't matter. In C++, we look at each token individually, and
decide what it is. Then we look whether it fits into the context where
it is used.

Looking at 4294967295, we see that we have an int. However, this int
is out-of-range, so the behaviour of the program is
implementation-defined. g++ gives a warning and assumes unsigned
(after it sees that it is used in an unsigned context).

The correct program would use

A<4294967295U> v;


More information about the Gcc-bugs mailing list