This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Strange pointer issue. Compiler setting?
- From: Karl Lindstrom <karllindstrom at mac dot com>
- To: libstdc++ at gcc dot gnu dot org
- Date: Sun, 31 Aug 2008 18:44:36 -0700
- Subject: Strange pointer issue. Compiler setting?
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