From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29736 invoked by alias); 2 Oct 2008 20:46:22 -0000 Received: (qmail 26742 invoked by uid 48); 2 Oct 2008 20:45:00 -0000 Date: Thu, 02 Oct 2008 20:46:00 -0000 Subject: [Bug c++/37722] New: destructors not called on computed goto X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "cburger at sunysb dot edu" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-10/txt/msg00201.txt.bz2 #include struct foo { foo() { std::cout << "foo constructed\n"; } ~foo() { std::cout << "foo destructed\n"; } }; enum opcode { NOP, FOO, DONE }; void exec0(const opcode* o) { loop: switch (*o) { case NOP: ++o; goto loop; case FOO: { foo f; ++o; goto loop; } // f destructed case DONE: return; } } void exec1(const opcode* o) { static void* label[] = { &&NOP, &&FOO, &&DONE }; goto *label[*o]; NOP: ++o; goto *label[*o]; FOO: { foo f; ++o; goto *label[*o]; } // f not destructed // FOO: { foo f; ++o; } goto *label[*o]; // work-around DONE: return; } int main() { const opcode program[] = { NOP, FOO, NOP, NOP, DONE }; exec0(program); exec1(program); return 0; } Output: foo constructed foo destructed foo constructed Tested with: 4.3.2, 4.2.4, 4.1.3, 3.4.6 Optimization level makes no difference. Intel icpc 10.1, 9.1 show the same problem. -- Summary: destructors not called on computed goto Product: gcc Version: 4.3.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: cburger at sunysb dot edu GCC build triplet: x86_64-linux-gnu GCC host triplet: x86_64-linux-gnu GCC target triplet: x86_64-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37722