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

            Bug ID: 118549
           Summary: -funreachable-traps doesn't transform trivial
                    unreachable into trap
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sjames at gcc dot gnu.org
  Target Milestone: ---

I was looking into a project getting a conversion to C23 unreachable wrong and
stumbled upon this.

```
[[gnu::noipa]]
void x(int x) {
        if (x == 1)
                __builtin_unreachable();
        __builtin_printf("got x=%d\n", x);
}

int main() {
        x(1);
        x(2);
        x(1);
}
```

`-funreachable-traps` is enabled for -O0 and -Og, but we don't ever trap here.
-fsanitize=undefined works, though.

Reply via email to