gcc/testsuite/g++.dg/uninit-pr105646.C
raw| 1 | // { dg-do compile } |
| 2 | // { dg-require-effective-target c++11 } |
| 3 | // { dg-options "-O2 -Wuninitialized" } |
| 4 | |
| 5 | int f1(); |
| 6 | int f2(){ |
| 7 | bool v2{v2}; // { dg-warning "is used uninitialized" } |
| 8 | auto const & a = f1(); |
| 9 | return a; |
| 10 | } |
| 11 | int f3(){ |
| 12 | auto const & a = f1(); |
| 13 | // Diagnose the following when optimizing and as unconditional |
| 14 | // uninitialized use despite f1 possibly throwing |
| 15 | bool v3{v3}; // { dg-warning "is used uninitialized" } |
| 16 | return a; |
| 17 | } |