This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/11584] ios::iword() fails to zero-initialize storage on failure
- From: "bkoz at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 17 Sep 2003 23:45:29 -0000
- Subject: [Bug libstdc++/11584] ios::iword() fails to zero-initialize storage on failure
- References: <20030718231013.11584.sebor@roguewave.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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