This is the mail archive of the gcc@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: Doubtful warning


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

Martin


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