This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/81555] New: Wrong code at -O1


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

            Bug ID: 81555
           Summary: Wrong code at -O1
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: babokin at gmail dot com
  Target Milestone: ---

gcc trunk, rev250545, x86_64.

> cat f.cpp
#include <stdio.h>

unsigned int var_1 = 1;
bool var_2 = false;
unsigned int var_3 = 679743406U;
unsigned int var_4 = 3054363510U;
bool var_5 = true;
unsigned char var_6 = 1;

void foo() {
  bool c = var_1 != var_2;
  if (c)
    var_5 = 0;
  if (var_4 & c & (unsigned char)var_3 & c)
    var_6 = 0;
}

int main() {
  foo();
  printf("%d, %d\n", var_5, var_6);
  return 0;
}

> g++ -O0 f.cpp -o out; ./out
0, 1

> g++ -O1 f.cpp -o out; ./out
0, 0

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]