This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/11584] New: ios::iword() fails to zero-initialize storage on failure
- From: "sebor at roguewave dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Jul 2003 23:10:15 -0000
- Subject: [Bug libstdc++/11584] New: ios::iword() fails to zero-initialize storage on failure
- 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
Summary: ios::iword() fails to zero-initialize storage on failure
Product: gcc
Version: 3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sebor at roguewave dot com
CC: gcc-bugs at gcc dot gnu dot org
According to 27.4.2.5, p3, of ISO/IEC 14882:2003, the program below is expected
to exit with the status of 0. It exits with a non-0 status when compiled with
gcc 3.2.
Regards
Martin
#include <stdlib.h>
#include <iostream>
#include <new>
int new_fails;
void* operator new (size_t n)
{
if (new_fails)
throw std::bad_alloc ();
return malloc (n);
}
void operator delete (void *p) { free (p); }
void* operator new[] (size_t n) { return operator new (n); }
void operator delete[] (void *p) { operator delete (p); }
int main ()
{
const int i = std::ios::xalloc ();
new_fails = 1;
std::cout.iword (i) = 0xdeadbeef;
return std::cout.iword (i);
}