[Bug tree-optimization/92506] New: [10 Regression] Wrong code with -fwrapv since r277979

marxin at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Nov 14 08:27:00 GMT 2019


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

            Bug ID: 92506
           Summary: [10 Regression] Wrong code with -fwrapv since r277979
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
  Target Milestone: ---

The following code snippet is isolated from postgresql package:

$ cat gego.c
int global;

struct Edge
{
  int edge_list;
};

void
gimme_gene(struct Edge edge) {
  int friend = edge.edge_list;
  if (friend < 0) {
    friend = (friend >= 0 ? friend : -friend);
    global = friend;
    __builtin_printf ("edge.edge_list:%d, friend: %d\n", edge.edge_list,
friend);
  }
}

int main(int argc, char **argv)
{
  struct Edge eee = { edge_list: -123 };
  gimme_gene (eee);
  if (global != 123)
    __builtin_abort ();
  return 0;
}

$ gcc -fwrapv gego.c -O2 && ./a.out 
edge.edge_list:-123, friend: -2147483648
Aborted (core dumped)

The problematic vrp1 transformation is:

Visiting statement:
friend_3 = -edge$edge_list_7;
Intersecting
  int ~[-2147483647, 0]
and
  int [-INF, -1]
to
  int [-INF, -2147483648]
Found new range for friend_3: int [-INF, -2147483648]


More information about the Gcc-bugs mailing list