Strange pointer issue. Compiler setting?

Karl Lindstrom karllindstrom@mac.com
Mon Sep 1 01:45:00 GMT 2008


Hello,

I am porting the C++ testsuite to an embedded environment.
The issue I am running into feels like a compiler setting problem,
and I am not sure...

In 27_io\basic_istream\ignore\char\3.cc, line 90 (or there abouts)
There is this call:

   state2 = ifstrm.rdstate();

Which returns the wrong value.
ifstrm is defined as:
    ifstream ifstrm;

When I go into the debugger and look at the "this" variable during  
the rdstate() call,
the protected values at the iso_base class level are offset by 4  
bytes from where they should be.
In other words, what should be in _M_flags is in the _M_width  
variable which preceeds _M_flags in the object definition.

If I modify the code and create a pointer to ifstrm, e.g.
  ifstream *ifp = &ifstrm;
and then call rdstate through the pointer, e.g.
   state2 = ifp->rdstate();

And look during the rdstate() call, "this" is pointing to a location  
that is 4 bytes less than before,
and the values all look correct.  They line up with how the protected  
variables look
when I look at the ifstrm object directly.

Has anyone ever seen anything like this?
I feel like there a compiler setting that I am missing.

In short, ifstrm.rdstate() fails (passes in wrong value for "this"),  
and ifp->rdstate() works.

Thanks.

-Karl




More information about the Libstdc++ mailing list