[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#295073: g++-3.3: operator new doesn't initialize memory anymore after thrown exception



Package: g++-3.3
Version: 1:3.3.5-5
Severity: normal


Dear g++ maintainer,

When running the following little program it appears that operator new fails
to initialize the memory it allocates. For example, when I run the program I
get the following output:

134517800 0 1074470752 1074986304 0 1 1 134517181 134517168 134515206 

The program was compiled using both a plain `g++' command and `g++ -Wall
-fexceptions'. No warnings are reported and compilation proceeds flawlessly. 

Here is the program;

------------------------------------------------
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

void showalloc()
{
    int *ip = new int [10];

    copy(ip, ip + 10, ostream_iterator<int>(cerr, " "));

    cout << endl;

    delete [] ip;
}

void thrower()
{
    try
    {
        throw 0;    // remove this to obtain memory initialized to 0
    }
    catch(...)
    {}
}

int main()
{
    thrower();
    showalloc();
    return 0;
}
------------------------------------------------

When the `throw 0;' statement is removed the memory comes out neatly
initialized. The program's output in that case is:

0 0 0 0 0 0 0 0 0 0 

Kind regards,

Frank B. Brokken

-- System Information:
Debian Release: 3.1
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.8.1
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages g++-3.3 depends on:
ii  gcc-3.3                     1:3.3.5-5    The GNU C compiler
ii  gcc-3.3-base                1:3.3.5-5    The GNU Compiler Collection (base 
ii  libc6                       2.3.2.ds1-20 GNU C Library: Shared libraries an
ii  libstdc++5-3.3-dev          1:3.3.5-5    The GNU Standard C++ Library v3 (d

-- no debconf information



Reply to: