Integer Overflow/Wrap and GCC Optimizations
Jeffrey Walton
noloader@gmail.com
Thu Jan 24 15:02:00 GMT 2013
Hi All,
I have a question on integer overflow and wrap, and GCC optimizations.
I have a small library that uses inline assembly to check OV/CY flags
for both x86/x64 and ARM. x86/x64 uses FLAGS/EFLAGS, while ARM uses
CPSR.
Do I have to worry about GCC optimizing out addition, subtractions,
etc under any circumstances?
I ask because the standard specifies overflow is undefined and wrap is
implementation defined. But I want to make sure the operation is
performed under all circumstances since I am using hardware to make
the determination. In the case of overflow or wrap, I will simply
discard the result and fail the function.
What I am not clear about is when an operation is deemed "undefined"
or "implementation defined".
Jeff
More information about the Gcc
mailing list