https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100317
Bug ID: 100317
Summary: 64-bit integer compare gives wrong result when
MIN_INT64 is one of the operands
Product: gcc
Version: 9.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: peshkoff at mail dot ru
Target Milestone: ---
Created attachment 50701
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50701&action=edit
Test demonstrating comparison bug
A problem happens in trivial function comparing absolute values of 64-bit
integers. If first operand is minimum int64 value (it's absolute value is
bigger than any 64-bit number) function returns wrong value (-1) when compiled
with -O2 or higher.
Attached example demonstrates that bug - compile it with or without -O2 and get
different results. That behavior can be "fixed" using hack under #ifdef
COMPARE_BUG_FIX, but correct comparison result is desired. I've set version in
the tracker to 9.3 - this is last version I've used to check, but versions 6.4,
6.5 and 8.3 are also affected.