Hello, I've compiled the code below using `g++ -Wuninitialized -O test.cc -o test': <<<<<<<<<<<<<<< bool cMyClass::Init() { bool retval; if (some_function()) { // If the `goto' is executed, 'return retval;' will use the // uninitialized value of 'retval'. goto error; } retval = true; error: return retval; } >>>>>>>>>>>>>>> The problem is explained in the code comments above. I think that GCC is supposed to warn about this, is that correct? Thanks, Jelle
We need a preprocessed self-contained, preferably small, testcase. Otherwise we cannot reproduce the bug ourselves. See http://gcc.gnu.org/bugs.html Thanks.
Created attachment 16086 [details] output of G++ with the `-v -save-temps' flags
Created attachment 16087 [details] the `.ii' file that G++ created
Please see the attachments I created for more information.
possible_bug.cc:1: error: `cMyClass' has not been declared possible_bug.cc: In function `bool Init()': possible_bug.cc:5: error: `some_function' was not declared in this scope possible_bug.cc:5: warning: unused variable 'some_function' Anyway, I guess the following reproduces the original problem: bool some_function(void); bool Init() { bool retval; if (some_function()) { // If the `goto' is executed, 'return retval;' will use the // uninitialized value of 'retval'. goto error; } retval = true; error: return retval; } which is converted to: bool Init() () { boolD.2365 retvalD.2430; boolD.2365 retval.0D.2432; # BLOCK 2 # PRED: ENTRY (fallthru,exec) [pr36814.C : 7] retval.0D.2432_2 = some_functionD.2427 (); [pr36814.C : 7] retval.0D.2432_3 = retval.0D.2432_2; [pr36814.C : 7] if (retval.0D.2432_3 != 0) goto <bb 4> (error); else goto <bb 3>; # SUCC: 4 (true,exec) 3 (false,exec) # BLOCK 3 # PRED: 2 (false,exec) [pr36814.C : 14] retvalD.2430_5 = 1; # SUCC: 4 (fallthru,exec) # BLOCK 4, starting at line 0 # PRED: 2 (true,exec) 3 (fallthru,exec) # retvalD.2430_1 = PHI <retvalD.2430_4(D)(2), 1(3)> errorL.1: return 1; # SUCC: EXIT } by the first CCP pass. So this is CCP again. *** This bug has been marked as a duplicate of 18501 ***