This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Integer Overflow/Wrap and GCC Optimizations
- From: Jeffrey Walton <noloader at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 24 Jan 2013 10:02:07 -0500
- Subject: Integer Overflow/Wrap and GCC Optimizations
- Reply-to: noloader at gmail dot com
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