This is the mail archive of the gcc@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]

Warning about variable optimized away?


Hello,

it it possible to get a kind of diagnostics if the variable
is totally optimized away?  For example, in:

void foo (struct some_type *obj) {
  ... some code where 'obj' is not used ...
  bar (obj->some_member);
  ... some code where 'obj' is not used again ...
  baz (obj->some_member);
}

'obj' is likely to be optimized away so only 'obj->some_member' really
exists (in a register or stack location).  Getting diagnostics
or preserving 'obj' may be important if there is a GC which scans
C stack and registers conservatively - if there is no direct reference
to 'obj', it's likely to be reclaimed and so 'obj->some_member'
becomes garbage.

Dmitry


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