[Bug tree-optimization/88753] Wrong code since r265463 in tree switch conversion

marxin at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jan 8 11:41:00 GMT 2019


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

--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
Reduced test-case:

$ cat zip.c
typedef unsigned short int uint16_t;
typedef unsigned char uint8_t;

uint16_t length;
uint16_t enc_method_global;

uint8_t
__attribute__((noipa))
_zip_buffer_get_8(int buffer)
{
  return buffer;
}

  int
  __attribute__((noipa))
foo(int v)
{
  uint16_t enc_method;
  switch (_zip_buffer_get_8(v)) {
    case 1:
      enc_method = 0x0101;
      break;
    case 2:
      enc_method = 0x0102;
      break;
    case 3:
      enc_method = 0x0103;
      break;
    default:
      __builtin_abort ();
  }

  enc_method_global = enc_method;
}

int main(int argc, char **argv)
{
  foo (1);
  if (enc_method_global != 0x0101)
    __builtin_abort ();

  return 0;
}


More information about the Gcc-bugs mailing list