[ forwarded from http://bugs.debian.org/429657 ]
[EMAIL PROTECTED]:/tmp% cat test.c
int abs(int j);
void abort(void);
__attribute__((noinline)) int lisp_atan2(long dy, long dx) {
if (dx <= 0)
if (dy > 0)
return abs(dx) <= abs(dy);
return 0;
}
int main() {
volatile long dy = 63, dx = -77;
if (lisp_atan2(dy, dx))
abort();
return 0;
}
[EMAIL PROTECTED]:/tmp% gcc-4.1 -O1 test.c && ./a.out
[EMAIL PROTECTED]:/tmp% gcc-4.1 -O2 test.c && ./a.out
zsh: abort ./a.out
not reproducible on alpha or amd64, or with 4.2.
--
Summary: wrong code with abs in comparison
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: falk at debian dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33142