[Bug libstdc++/11584] ios::iword() fails to zero-initialize storage on failure
bkoz at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Wed Sep 17 23:50:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11584
------- Additional Comments From bkoz at gcc dot gnu dot org 2003-09-17 23:45 -------
On closer examination, I don't think this is a bug.
For one thing:
int i = std::ios::xalloc();
std::cout.iword (i) = 0xdeadbeef;
long l = std::cout.iword (i);
l == 0xdeadbeef;
is valid, based on the fact that the index is the same (regardless of the
replacement operator new).
If, instead:
void test01()
{
bool test = true;
new_fails = 1;
const int i = std::ios::xalloc();
std::cout.iword(i) = 0xdeadbeef;
long l1 = std::cout.iword(i);
VERIFY( l1 == 0xdeadbeef);
long l2 = std::cout.iword(i * 3);
VERIFY( l2 == 0 );
// The reference returned may become invalid after another call to
// the object's iword member with a different index. NB: Note the
// 'may': it's not required, and in this case should not be
// required, as the i size array is still allocated.
long l3 = std::cout.iword(i);
VERIFY( l3 == 0 || l3 == 0xdeadbeef);
}
-benjamin
More information about the Gcc-bugs
mailing list