Bug 38945 - No warning when using uninitialized variable
No warning when using uninitialized variable
Status: RESOLVED DUPLICATE of bug 18501
Product: gcc
Classification: Unclassified
Component: c
4.3.2
: P3 minor
: ---
Assigned To: Not yet assigned to anyone
:
Depends on:
Blocks: Wuninitialized
  Show dependency treegraph
 
Reported: 2009-01-23 14:36 UTC by Fredrik Hederstierna
Modified: 2009-01-26 19:27 UTC (History)
11 users (show)

See Also:
Host: x86-intel
Target: arm-elf-gcc
Build: arm-elf-gcc
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 ***