[Bug libstdc++/26123] [3.4/4.0 Regression] Segmentation fault in constructor of std::ostream::sentry::sentry

rguenth at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Mon Feb 6 15:07:00 GMT 2006



------- Comment #7 from rguenth at gcc dot gnu dot org  2006-02-06 15:07 -------
I think this is undefined.  Reduced testcase:

extern "C" void *malloc(__SIZE_TYPE__ n);
int mkCint();
const int cInt = mkCint();
struct Ptr {
  Ptr() { ptr = (int *)malloc(sizeof(int)); }
  int *ptr;
};
Ptr p;
int main()
{
  *p.ptr = mkCint();
}
int mkCint()
{
  return *p.ptr;
}

how should we know to initialize std::cout first?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26123



More information about the Gcc-bugs mailing list