From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26930 invoked by alias); 26 Aug 2011 12:52:57 -0000 Received: (qmail 26920 invoked by uid 22791); 26 Aug 2011 12:52:56 -0000 X-SWARE-Spam-Status: No, hits=0.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-vx0-f175.google.com (HELO mail-vx0-f175.google.com) (209.85.220.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 26 Aug 2011 12:52:43 +0000 Received: by vxj14 with SMTP id 14so2775986vxj.20 for ; Fri, 26 Aug 2011 05:52:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.52.173.226 with SMTP id bn2mr988053vdc.505.1314363162400; Fri, 26 Aug 2011 05:52:42 -0700 (PDT) Received: by 10.52.188.97 with HTTP; Fri, 26 Aug 2011 05:52:42 -0700 (PDT) Date: Fri, 26 Aug 2011 12:52:00 -0000 Message-ID: Subject: linking time eroor with -fast-math -O0 From: Vladimir Yakovlev To: gcc@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2011-08/txt/msg00419.txt.bz2 Hi, Following test fails in linking if compiled with ffast-math and O0, but it compiled successfully with ffast-math and O2. Also no problem if -lm is added. $ cat t.c #include float foo(float x) { float y = 0; while (x > 0.00000001) { y += x*x*x*x*x*x*x*x*x*x*x*x*x; x = x/2; } return y; } int main (int argc, char *argv[]) { float y = atoi(argv[1]); printf("%f\n", foo(y)); return 0; } $ gcc -ffast-math -O0 t.c /tmp/cccA1sUB.o: In function `foo': t.c:(.text+0x2c): undefined reference to `powf' collect2: error: ld returned 1 exit status $ gcc -ffast-math -O2 t.c $ ./a.out 5 1220852096.000000 FE with -ffast-math replaced x*x*...*x with __builtin_powf. Later with -O2 this call is replaced back into multiplications in sincos phase. The stability with -O0 is because sincos phase doesn't work on -O0. I think we must avoid doing this optimization in FE and turn off -ffast-math if -O0 is used. Your opinion. Thanks, Vladimir