#include <string> template <class _Tp> class AutoPtr { _Tp* _M_ptr;
public: explicit AutoPtr(_Tp* __p = 0) : _M_ptr(__p) {} ~AutoPtr() { delete _M_ptr; } _Tp* operator->() const { return _M_ptr; } }; struct A { virtual ~A(); virtual A * unserialise(const std::string &s) const = 0; }; A * wtx; void func(const std::string & s) { AutoPtr<A> wt(wtx->unserialise(s.c_str())); } g++ -O -Wuninitialized -c remoteserver.cc remoteserver.cc: In function 'void func(const std::string&)': remoteserver.cc:9: warning: 'wt.AutoPtr<A>::_M_ptr' is used uninitialized in this function remoteserver.cc:26: note: 'wt.AutoPtr<A>::_M_ptr' was declared here because in the late uninitalized variable pass we discover <L1>:; save_filt.37_16 = <<<filter object>>>; save_eptr.36_17 = <<<exception object>>>; if (wt$_M_ptr_40(D) != 0B) goto <bb 12>; else goto <bb 13>; <bb 12>: D.13202_23 = wt$_M_ptr_40(D)->_vptr.A; D.13203_24 = D.13202_23 + 8; D.13204_25 = *D.13203_24; OBJ_TYPE_REF(D.13204_25;wt$_M_ptr_40(D)->1) (wt$_M_ptr_40(D)); which hasn't been deleted here. 4.2 was either able to delete these BBs or didn't create this exception region. -- Summary: [4.3 Regression] uninitialized variable warning in dead exception region Product: gcc Version: 4.3.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: rguenth at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34196