Debian Codegraph @

gcc/testsuite/g++.dg/ubsan/return-8e.C

raw
1 // PR c++/104642
2
3 // At -O0 and -Og we default to -funreachable-traps
4 // so the below should abort at runtime.
5
6 // { dg-do run }
7 // { dg-shouldfail { *-*-* } }
8 // { dg-additional-options "-O2" }
9
10 bool b;
11
12 __attribute__ ((optimize ("Og")))
13 int f() {
14 if (b) return 42;
15 } // { dg-warning "-Wreturn-type" }
16
17 int main() { f(); }