https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98373
H.J. Lu <hjl.tools at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|WAITING |NEW --- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> --- [hjl@gnu-cfl-2 gold]$ cat /tmp/foo.cc template<int size> struct Sym_data; template<> struct Sym_data<32> { unsigned char st_info; unsigned char st_other; }; template<> struct Sym_data<64> { unsigned char st_info; unsigned char st_other; }; template<int size, bool big_endian> class Sym { public: Sym(const unsigned char* p) : p_(reinterpret_cast<const Sym_data<size>*>(p)) { } private: const Sym_data<size>* p_; }; template<int size, bool big_endian> class Sized_relobj_incr { private: void do_add_symbols(); Sym<size, big_endian> *symbols_; }; template<int size, bool big_endian> Sym<size, big_endian> * foo(Sym<size, big_endian> *); template<int size, bool big_endian> void Sized_relobj_incr<size, big_endian>::do_add_symbols() { unsigned char symbuf[100]; Sym<size, big_endian> sym(symbuf); Sym<size, big_endian>* res = foo(&sym); this->symbols_ = res; } template class Sized_relobj_incr<32, false>; [hjl@gnu-cfl-2 gold]$ /usr/gcc-11.0.0-x32/bin/g++ -Wall -S /tmp/foo.cc /tmp/foo.cc: In member function ‘void Sized_relobj_incr<size, big_endian>::do_add_symbols() [with int size = 32; bool big_endian = false]’: /tmp/foo.cc:47:25: warning: ‘symbuf’ may be used uninitialized [-Wmaybe-uninitialized] 47 | Sym<size, big_endian> sym(symbuf); | ^~~ /tmp/foo.cc:22:3: note: by argument 2 of type ‘const unsigned char*’ to ‘Sym<size, big_endian>::Sym(const unsigned char*) [with int size = 32; bool big_endian = false]’ declared here 22 | Sym(const unsigned char* p) | ^~~ /tmp/foo.cc:46:17: note: ‘symbuf’ declared here 46 | unsigned char symbuf[100]; | ^~~~~~ [hjl@gnu-cfl-2 gold]$