This one should not abort: #include <math.h> #include <stdlib.h> int main() { double x = -1.0; if (sqrt(pow(x,2)) != 1.0) abort(); return 0; } but both, 3.4.4 and 4.0.0 do sqrt(pow(x,y)) -> pow(x,y*0.5) which in this case means sqrt(1.0) -> -1.0. Ouch.
Confirmed but you forgot the most important thing (even though you did say this on the mailing lists), the options you used to reproduce the failure. -funsafe-math-optimizations is needed to reproduce this.
Subject: Bug 19775 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: rguenth@gcc.gnu.org 2005-02-03 17:47:33 Modified files: gcc : ChangeLog builtins.c gcc/testsuite : ChangeLog gcc/testsuite/gcc.dg: builtins-10.c Added files: gcc/testsuite/gcc.dg: builtins-47.c Log message: PR middle-end/19775 * builtins.c (fold_builtin_sqrt): Transform sqrt(pow(x,y)) to pow(fabs(x),y*0.5), not pow(x,y*0.5). * gcc.dg/builtins-10.c: Disable test for invalid transformation and one test we no longer optimize. * gcc.dg/builtins-47.c: New testcase. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.791&r2=2.2326.2.792 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/builtins.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.275.2.5&r2=1.275.2.6 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.355&r2=1.3389.2.356 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/builtins-47.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/builtins-10.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.1&r2=1.1.22.1
Subject: Bug 19775 CVSROOT: /cvs/gcc Module name: gcc Changes by: rguenth@gcc.gnu.org 2005-02-07 13:24:38 Modified files: gcc : ChangeLog builtins.c gcc/testsuite : ChangeLog gcc/testsuite/gcc.dg/torture: builtin-power-1.c gcc/testsuite/gcc.dg: builtins-10.c Added files: gcc/testsuite/gcc.dg: builtins-47.c Log message: 2005-02-07 Richard Guenther <rguenth@gcc.gnu.org> PR middle-end/19775 * builtins.c (fold_builtin_sqrt): Transform sqrt(pow(x,y)) to pow(fabs(x),y*0.5), not pow(x,y*0.5). * gcc.dg/torture/builtin-power-1.c: Disable test for invalid transformation. * gcc.dg/builtins-10.c: Likewise. Disable one test we no longer optimize. * gcc.dg/builtins-47.c: New testcase. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.7408&r2=2.7409 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/builtins.c.diff?cvsroot=gcc&r1=1.415&r2=1.416 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4998&r2=1.4999 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/torture/builtin-power-1.c.diff?cvsroot=gcc&r1=1.1&r2=1.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/builtins-47.c.diff?cvsroot=gcc&r1=1.1&r2=1.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/builtins-10.c.diff?cvsroot=gcc&r1=1.1&r2=1.2
Fixed.