Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.
This repository was archived by the owner on May 14, 2024. It is now read-only.

Incorrect constraints collecting under O3 #3

Description

@chenju2k6

In the below program, when LOOP_COUNT > 3, there are no constraints generated when the optimization level is set to O3


#define LOOP_COUNT 4
int main(int argc, char **argv) {

  if (argc < 2)
    return 0;

  FILE *fp;
  char buf[255];
  size_t ret;

  fp = fopen(argv[1], "rb");

  if (!fp) {
    printf("st err\n");
    return 0;
  }

  int len = 20;
  ret = fread(buf, sizeof *buf, len, fp);
  fclose(fp);
  int count = 0;
  for(int i=0;i<LOOP_COUNT;i++) {
    switch (buf[i]) {
      case 'u':
        count++;
        break;
      default:
        break;
    }
  }
  switch (count) {
    case 2:
      printf("hit!\n");
      abort();
    default:
      break;
  }
  return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions