https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105646
Bug ID: 105646
Summary: g++ does not raise xxx is used uninitialized warning
under some conditions
Product: gcc
Version: 12.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: cfy1990 at gmail dot com
Target Milestone: ---
g++ version: g++ (Compiler-Explorer-Build-gcc--binutils-2.38) 12.1.0
Code link: https://godbolt.org/z/5MansKa5c
Compile arguments: -std=c++11 -Wextra -Wall -O2
Code:
int f1();
int f2(){
bool v2{v2}; // used uninitialized warning
auto const & a = f1();
return a;
}
int f3(){
auto const & a = f1();
bool v3{v3}; // no warning in g++, got uninitialized warning in clang
return a;
}