Mail Archives: djgpp/2000/01/11/06:54:56
Michael Farnham (MCFARNHAM AT prodigy DOT net) wrote:
: I have done some code testing and have come to some conclusions.
: * With no optimizations turned on and when s is an int the loop
: quits when s = INT_MAX (from limits.h or climits).
: * When s is a char s + 1 is implicitly converted to int and the
: loop is infinite.
: * If s is a type where the maximum value is less than INT_MAX
: (e.g. CHAR_MAX < INT_MAX), then s + 1 will be converted to an
: int and the loop will be infinite. If s is an int then the
: loop will terminate when s = INT_MAX.
: * If the only purpose of this loop is to identify the maximum
: value for the type then it would be easier to use the value
: defined in the standard header file limits.h (C) or climits (C++).
How about giving gcc the -S option and look at the resulting assembly
code to figure out how gcc compiles it?
This Mortal Coil, Blood,
MartinS
- Raw text -