Bug 17191 - address taken prevents uninitialized variable warning
Summary: address taken prevents uninitialized variable warning
Status: RESOLVED DUPLICATE of bug 179
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.4.1
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-25 21:13 UTC by nomura
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
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 nomura 2004-08-25 21:13:25 UTC
Compiling this code with -O -Wall should warn that "i" is used without
being initialized.  The presence of "p = &i" stops this warning
from being issued, but the address is not exposed in a way that could
affect i.  (No path from the address taken to the use, and the variable 
is local).  If the uninit warning could be strengthened it would have
real benefits.

-- Source code:

int *p;

void foo ()
{
        int i;
        if (i < 100)
                return;
        p = &i;
}

-- Command line:

[gecko]$ xgcc-3.4 -v -c -O2 a.c -Wall -Werror
Reading specs from /u/nomura/dl/gcc-3.4.1_linux/gcc/specs
Configured with: ../gcc-3.4.1/configure --enable-languages=c,c++
--prefix=/x/sim/nomura/root.linux/gcc-3.4.1
Thread model: posix
gcc version 3.4.1
 /u/nomura/dl/gcc-3.4.1_linux/gcc/cc1 -quiet -v -iprefix
/u/nomura/dl/gcc-3.4.1_linux/gcc/../lib/gcc/i686-pc-linux-gnu/3.4.1/ -isystem
/u/nomura/dl/gcc-3.4.1_linux/gcc/include a.c -quiet -dumpbase a.c
-mtune=pentiumpro -auxbase a -O2 -Wall -Werror -version -o /tmp/ccN7EB39.s
ignoring nonexistent directory
"/u/nomura/dl/gcc-3.4.1_linux/gcc/../lib/gcc/i686-pc-linux-gnu/3.4.1/include"
ignoring nonexistent directory
"/u/nomura/dl/gcc-3.4.1_linux/gcc/../lib/gcc/i686-pc-linux-gnu/3.4.1/../../../../i686-pc-linux-gnu/include"
ignoring nonexistent directory
"/x/sim/nomura/root.linux/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /u/nomura/dl/gcc-3.4.1_linux/gcc/include
 /usr/local/include
 /x/sim/nomura/root.linux/gcc-3.4.1/include
 /x/sim/nomura/root.linux/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/include
 /usr/include
End of search list.
GNU C version 3.4.1 (i686-pc-linux-gnu)
        compiled by GNU C version 3.2 20020903 (Red Hat Linux 8.0 3.2-7).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
 /x/sim/nomura/root.linux/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/../../../../i686-pc-linux-gnu/bin/as
--traditional-format -V -Qy -o a.o /tmp/ccN7EB39.s
GNU assembler version 2.15 (i686-pc-linux-gnu) using BFD version 2.15
[gecko]$
Comment 1 Andrew Pinski 2004-08-25 21:16:17 UTC

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