[Bug tree-optimization/126467] New: wrong code with folding 0.0 - x

"ktkachov at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126467

            Bug ID: 126467
           Summary: wrong code with folding 0.0 - x
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ktkachov at gcc dot gnu.org
  Target Milestone: ---

__attribute__((noipa)) double
f (double y)
{
  return 0.0 - __builtin_fabs (y);
}

int
main (void)
{
  if (__builtin_signbit (f (-0.0)))
    __builtin_abort ();
  if (__builtin_signbit (f (0.0)))
    __builtin_abort ();
  return 0;
}

aborts with GCC but passes with Clang.
 0.0 - x is not -x: for x == +0.0 the subtraction gives +0.0 while the negation
gives -0.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.