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]
Other format: [Raw text]

Integer Overflow/Wrap and GCC Optimizations


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


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