c++/7322: Code to Compute Numeric Limits "runs away" when -O<any> used
Tue Jul 16 01:44:00 GMT 2002
Synopsis: Code to Compute Numeric Limits "runs away" when -O<any> used
State-Changed-When: Tue Jul 16 01:41:42 2002
The code is ill formed.
There are tests such as
if (T (max + 1) > max)
where max & T are signed types. /5 says that
if the result is not in the range if representable values,
the behaviour is undefined. gcc implements modulo arithmetic
for unsigned types, and undefined behaviour for signed types.
The optimized therefore knows that max + 1 must always
be greater than max.
More information about the Gcc-bugs