public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/103406] New: gcc -O0 behaves differently on "DBL_MAX related operations" than gcc -O1 and above
@ 2021-11-24 11:09 shaohua.li at inf dot ethz.ch
  2021-11-24 11:21 ` [Bug c/103406] " pinskia at gcc dot gnu.org
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: shaohua.li at inf dot ethz.ch @ 2021-11-24 11:09 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103406

            Bug ID: 103406
           Summary: gcc -O0 behaves differently on "DBL_MAX related
                    operations" than gcc -O1 and above
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: shaohua.li at inf dot ethz.ch
  Target Milestone: ---

Hi there,

I found that for a piece of code, gcc would give out different results when
compiled with different opt flags.

- gcc version: 11.1.0

- Platform: Ubuntu 20.04, x86_64

$gcc a.c -O0; ./a.out
nan
$
$
$gcc a.c -O1; ./a.out
-nan
$
$
$cat a.c

#include <stdio.h>
#include <float.h>

#define INFINITY (DBL_MAX+DBL_MAX)
#define NAN (INFINITY-INFINITY)

void main() {
  double x = -NAN;
  double y = NAN;
  double z = x + y;
  printf("%lf\n", z);
}

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2021-11-26 17:58 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-24 11:09 [Bug c/103406] New: gcc -O0 behaves differently on "DBL_MAX related operations" than gcc -O1 and above shaohua.li at inf dot ethz.ch
2021-11-24 11:21 ` [Bug c/103406] " pinskia at gcc dot gnu.org
2021-11-24 11:23 ` ubizjak at gmail dot com
2021-11-24 11:29 ` pinskia at gcc dot gnu.org
2021-11-24 11:54 ` rguenth at gcc dot gnu.org
2021-11-24 12:01 ` rguenth at gcc dot gnu.org
2021-11-24 12:02 ` rguenth at gcc dot gnu.org
2021-11-24 12:03 ` [Bug middle-end/103406] [12 Regression] " rguenth at gcc dot gnu.org
2021-11-24 12:29 ` roger at nextmovesoftware dot com
2021-11-24 13:02 ` rguenth at gcc dot gnu.org
2021-11-24 13:04 ` rguenth at gcc dot gnu.org
2021-11-24 13:05 ` rguenth at gcc dot gnu.org
2021-11-24 22:22 ` joseph at codesourcery dot com
2021-11-25 19:04 ` cvs-commit at gcc dot gnu.org
2021-11-25 19:40 ` [Bug middle-end/103406] " roger at nextmovesoftware dot com
2021-11-25 20:29 ` joseph at codesourcery dot com
2021-11-26 17:58 ` roger at nextmovesoftware dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).