Bug 38945

Summary: No warning when using uninitialized variable
Product: gcc Reporter: Fredrik Hederstierna <fredrik>
Component: cAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: minor CC: dberlin, fredrik, gcc-bugs, jellegeerts, manu, mark, mueller, P.Schaffnit, pinskia, satyam, thutt
Priority: P3    
Version: 4.3.2   
Target Milestone: ---   
Host: x86-intel Target: arm-elf-gcc
Build: arm-elf-gcc Known to work:
Known to fail: Last reconfirmed:
Bug Depends on:    
Bug Blocks: 24639    

Description Fredrik Hederstierna 2009-01-23 14:36:13 UTC
The 4.x compilers does not warn when using unset variables.
The 3.x compilers did warn on this:

Example:

int use_unset_variable(int y)
{
  int x;
  switch(y) {
  case 0:
    x = 0;
    break;
  default:
    break;
  }
  x++;
  return x;
}

Variable x could be unset when returning.
I use all warnings possible:

-Wall -W -Wextra

Best Regards
Fredrik
Comment 1 Manuel López-Ibáñez 2009-01-24 16:05:13 UTC
I am almost sure that this is CCP again assuming that the undefined value is the same as the constant assigned, hence x++ is converted to 0++. This can be checked using -fdump-tree-all-all-lineno.

If so, a duplicate of bug 18501.
Comment 2 Andrew Pinski 2009-01-26 19:27:15 UTC
Yes this is a dup of bug 18501.

*** This bug has been marked as a duplicate of 18501 ***