This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/33279] Failed to warn uninitialized stack variable



------- Comment #1 from pinskia at gmail dot com  2007-09-02 13:26 -------
Subject: Re:  New: Failed to warn uninitialized stack variable

On 2 Sep 2007 13:19:45 -0000, hjl at lucon dot org
<gcc-bugzilla@gcc.gnu.org> wrote:
> [hjl@gnu-26 uninit-2]$ cat x.c
> typedef int mpz_t[1];
> typedef struct iterator_stack
> {
>   struct iterator_stack *prev;
>   mpz_t value;
> } iterator_stack;
> iterator_stack *x;
> void bar (mpz_t);
> void
> foo ()
> {
>   iterator_stack frame;
>   bar (frame.value);
>   x = frame.prev;
> }
> [hjl@gnu-26 uninit-2]$ make
> /export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
> -B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -O2 -Wuninitialized -S x.c


Not really because this is the same as
bar (&frame.value[0]);

Where bar can do pointer tricks to get back to original struct and
then change prev, trust me, this is allowed.  There is a comment in
GCC sources about this specific issue.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33279


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]