Bug 34461 - program crashes when using a try-catch-block around a constructor
Summary: program crashes when using a try-catch-block around a constructor
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-14 09:50 UTC by Christian Matuszewski
Modified: 2007-12-14 13:16 UTC (History)
1 user (show)

See Also:
Host: i386-redhat-linux
Target: i686-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
test case to reproduce the bug (100.11 KB, text/plain)
2007-12-14 09:52 UTC, Christian Matuszewski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Matuszewski 2007-12-14 09:50:56 UTC
The test case contains a constructor which is surrounded by a try-catch-block. Inside the constructor some memory is allocated and an exception is thrown. In the catch-block the previously allocated memory is freed which leads to an unexpected segmentation fault. Changing the constant 16 in the test case to 15 or lower lets the program run as expected.

Output of gcc -v:
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.2.2/configure --prefix=/home/matuszewski/gcc-4.2.2 --program-suffix=-4.2.2
Thread model: posix
gcc version 4.2.2

The bug also occurs with gcc version 3.4.6

The bug is triggerd with calling "./PlayGround".
Comment 1 Christian Matuszewski 2007-12-14 09:52:44 UTC
Created attachment 14752 [details]
test case to reproduce the bug
Comment 2 Richard Biener 2007-12-14 13:16:24 UTC
15.3/10  Referring to any non-static member or base class of an object in the
handler for a function-try-block of a constructor or destructor for that object
results in undefined behavior.