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

2007-09-02 Thread pinskia at gmail dot com


--- 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 -, hjl at lucon dot org
[EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] 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;
 }
 [EMAIL PROTECTED] 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



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

2007-09-02 Thread pinskia at gcc dot gnu dot org


--- Comment #2 from pinskia at gcc dot gnu dot org  2007-09-02 13:32 ---
As mentioned by me in comment #1, we cannot warn about this.


-- 

pinskia at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution||INVALID


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



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

2007-09-02 Thread hjl at lucon dot org


--- Comment #3 from hjl at lucon dot org  2007-09-02 13:37 ---
 Subject: Re:  New: Failed to warn uninitialized stack variable

 
 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.
 

How does bar know it is called by

bar (frame.value);

not

mpz_t value;
...
bar (value);


-- 

hjl at lucon dot org changed:

   What|Removed |Added

 Status|RESOLVED|UNCONFIRMED
 Resolution|INVALID |


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



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

2007-09-02 Thread pinskia at gcc dot gnu dot org


--- Comment #4 from pinskia at gcc dot gnu dot org  2007-09-02 13:43 ---
  bar (frame.value);
That call to bar causes the whole frame struct escapes here, not just the array
element.  

void bar (mpz_t);
is really:
void bar(int*);

because of array decaying in parameters.

Again with pointer arithmetic, bar can get back to the original struct and be
able to set prev.  So again there is no bug here.


-- 

pinskia at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution||INVALID


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



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

2007-09-02 Thread hjl at lucon dot org


--- Comment #5 from hjl at lucon dot org  2007-09-02 13:56 ---
(In reply to comment #4)
   bar (frame.value);
 That call to bar causes the whole frame struct escapes here, not just the 
 array
 element.  
 
 void bar (mpz_t);
 is really:
 void bar(int*);
 
 because of array decaying in parameters.
 
 Again with pointer arithmetic, bar can get back to the original struct and be
 able to set prev.  So again there is no bug here.
 

When bar is called from

mpz_t value;
...
bar (value);

there is no original struct to go back to and there can be another
struct

typedef struct iterator_stack_2
{
  struct iterator_stack_2 *prev;
  mpz_t value;
  int foo;
} iterator_stack_2;

iterator_stack_2 x;
..
bar (x.value);

What does bar get back to? Are you saying if a pointer is passed to bar,
it can get back to any original struct where the pointer is a field?


-- 

hjl at lucon dot org changed:

   What|Removed |Added

 Status|RESOLVED|UNCONFIRMED
 Resolution|INVALID |


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



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

2007-09-02 Thread hjl at lucon dot org


--- Comment #6 from hjl at lucon dot org  2007-09-02 13:58 ---
(In reply to comment #5)

 
 What does bar get back to? Are you saying if a pointer is passed to bar,
 it can get back to any original struct where the pointer is a field?
 

If you can write such a function, I can pass you a pointer and your function
will be wrong.


-- 


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



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

2007-09-02 Thread Andrew Pinski
On 2 Sep 2007 13:56:13 -, hjl at lucon dot org
[EMAIL PROTECTED] wrote:
 What does bar get back to? Are you saying if a pointer is passed to bar,
 it can get back to any original struct where the pointer is a field?


It only matters at the context at the point bar is called with the
struct.  No other place matters.  It does not matter if bar can be
called with a simple array (that will cause undefined code if bar
tries to go before the array) as it still can be using pointer
arithmetic.


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

2007-09-02 Thread pinskia at gmail dot com


--- Comment #7 from pinskia at gmail dot com  2007-09-02 14:01 ---
Subject: Re:  Failed to warn uninitialized stack variable

On 2 Sep 2007 13:56:13 -, hjl at lucon dot org
[EMAIL PROTECTED] wrote:
 What does bar get back to? Are you saying if a pointer is passed to bar,
 it can get back to any original struct where the pointer is a field?


It only matters at the context at the point bar is called with the
struct.  No other place matters.  It does not matter if bar can be
called with a simple array (that will cause undefined code if bar
tries to go before the array) as it still can be using pointer
arithmetic.


-- 


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



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

2007-09-02 Thread Andrew Pinski
On 2 Sep 2007 13:58:23 -, hjl at lucon dot org
[EMAIL PROTECTED] wrote:

 If you can write such a function, I can pass you a pointer and your function
 will be wrong.

yes so but that call would be undefined, not the one we are talking
about currently.

--Pinski


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

2007-09-02 Thread pinskia at gmail dot com


--- Comment #8 from pinskia at gmail dot com  2007-09-02 14:02 ---
Subject: Re:  Failed to warn uninitialized stack variable

On 2 Sep 2007 13:58:23 -, hjl at lucon dot org
[EMAIL PROTECTED] wrote:

 If you can write such a function, I can pass you a pointer and your function
 will be wrong.

yes so but that call would be undefined, not the one we are talking
about currently.

--Pinski


-- 


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



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

2007-09-02 Thread rguenth at gcc dot gnu dot org


--- Comment #9 from rguenth at gcc dot gnu dot org  2007-09-02 14:03 ---
What does bar get back to? Are you saying if a pointer is passed to bar,
it can get back to any original struct where the pointer is a field?

No, but if you pass a pointer to a field of a struct the callee may derive
the address of the containing object and modify it.


-- 


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



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

2007-09-02 Thread pinskia at gcc dot gnu dot org


--- Comment #10 from pinskia at gcc dot gnu dot org  2007-09-02 17:19 
---
As mentioned by Richard and I, this bug is invalid.


-- 

pinskia at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution||INVALID


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