This test case provokes spurious "is used uninitialized" warnings from trunk GCC. #include <string> #include <memory> class HashFunction {}; HashFunction *get_hash (std::string const &); void generate_dsa_primes (void) { std::auto_ptr <HashFunction> hash(get_hash("SHA-160")); } -> backward/auto_ptr.h: In function 'void generate_dsa_primes()': backward/auto_ptr.h:177: warning: 'hash.std::auto_ptr<HashFunction>::_M_ptr' is used uninitialized in this function dsa_gen.cc:6: note: 'hash.std::auto_ptr<HashFunction>::_M_ptr' was declared here This does not happen with 4.2.3. Note that the warnings go away if you change get_hash to take a const char * instead of a std::string const &, which seems like it shouldn't matter.
Created attachment 14756 [details] -fdump-tree-optimized output I looked at the -fdump-tree-optimized output (attached) and it makes somewhat more sense that the presence of std::string would matter -- the code generated to convert the string constant to a std::string object introduces seriously nontrivial control flow. However, that's not an excuse.
Ooh, it gets worse. The spurious diagnostic is a symptom of an incorrect optimization. In normal control flow, the result of get_hash is assigned to a synthetic variable, D.13336, and that variable is used to call operator delete in basic block 14. However, an exception might transfer control to label L1 (not a basic block?!) which calls operator delete on hash$_M_ptr, which has never been initialized.
I think this is a dup of PR34196. You might want to add something about the wrong-code bits there.
How do you know whether an EH region is dead? That information does not seem to be in the dumps.
(In reply to comment #4) > How do you know whether an EH region is dead? That information does not seem > to be in the dumps. the summary of that other bug is incorrect. I already added information about the wrong code in the other bug. See my comment #1.
"How do you know whether an EH region is dead" is still a live question for this bug. Not turning hash$_M_ptr into D.13336 is only a wrong-code bug if the block can be executed.
Leaving as P3 until we know whether this is actually wrong code or not.
At least confirmed. Jason, would you have a look here?
P2, until we know if this is actually wrong code.
dup. don't count this twice. *** This bug has been marked as a duplicate of 34196 ***
Subject: Re: [4.3 regression] spurious "is used uninitialized" from auto_ptr I'm not convinced it is a duplicate; no one has determined whether or not the EH region in my case is actually dead.