the following command
g++ -g -S -dA -fno-strict-aliasing test_enum_cast2.cxx

produces 
       # test_enum_cast2.cxx:13
        .loc 1 13 0
        movl    -12(%ebp), %eax
        incl    %eax
        movw    %ax, -2(%ebp)

which shows a movl for a short variable.

This is interpreted as possibly uninitialized memory read by purify (depending
on other stack variables and if they are initialized). Rational/IBM tells me
they do report the actual behaviour. Is there a way to avoid this movl and use
really word size? (I expect this to be an optimization but it hurds in this 
case)

the example is:
test_enum_cast2.cxx:
struct KEY{
  const char *name; //if removed this line then no error in purify (as it then 
reads
from initialized variable var set to 1 from the stack
  short type;
 };


int main(){
 short var=1; //if this is left uninit and key.type is set to 1 directly then no
erro
r in purify
 KEY key;
  key.name=0;
  key.type=var;

   var = key.type + 1;

 }

Thanks Dirk-Jan

-- 
           Summary: reading other stack variable memory space for shorts
           Product: gcc
           Version: 3.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dirkjan at magma-da dot com
                CC: gcc-bugs at gcc dot gnu dot org


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

Reply via email to