public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/14535] New: exception throwing in virtual function doesn't turn on the local destructors
@ 2004-03-11 14:30 lassinovsky at algorithm dot aelita dot com
  2004-03-11 14:33 ` [Bug optimization/14535] " lassinovsky at algorithm dot aelita dot com
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: lassinovsky at algorithm dot aelita dot com @ 2004-03-11 14:30 UTC (permalink / raw)
  To: gcc-bugs

The following conditions do cause the bug:
1. Optimized compilation (-O1,-O2, -O3)
2. Overriding virtual function is called through the base class pointer or 
    reference
3. Overriding virtual function calls any object method, which has exception 
specification and throws an exception.
4. Overriding virtual function doesn't have an exception specification.

My configuration:
uname -a:
SunOS dog 5.8 Generic_108529-09 i86pc i386 i86pc

gcc -v
Reading specs from /opt/AESgcc/lib/gcc-lib/i386-pc-solaris2.8/3.2/specs
Configured with: /export/home/Ext/Archive/gcc-3.2/configure --
prefix=/opt/AESgcc --disable-multilib --enable-threads=posix --enable-
languages=c,c++ --with-gnu-ld --with-ld=/usr/local/bin/ld --with-gnu-as -with-
as=/usr/local/bin/as
Thread model: posix
gcc version 3.2

Test case:
======= Test case starts
#include <iostream>

class Raiser
{
public:
    Raiser()  throw( int )
    {
        throw 1;
    };
};

class Object
{
public:
    virtual ~Object()
    {
        std::cout << "~Object()" << std::endl;
    };
};


class Base
{
public:
    virtual ~Base(){};
    virtual void Run(){};
};


class FromBase : public Base
{
public:
    virtual ~FromBase(){};
    virtual void Run()
    {
        std::cout << "Derived Run" << std::endl;
        {
            Object a;
            std::cout << "Raise!" << std::endl;
            Raiser   riser;
        }
        std::cout << "Unreachable code" << std::endl;
    };
};

int main()
{
    FromBase a;
    Base& b = static_cast<Base&>(a);
    
    try
    {
        b.Run();
        std::cout << "Unreach 2" << std::endl;
    }
    catch ( int ) 
    {
        std::cout << "Exception handler" << std::endl;
    }
    
    std::cout << "Exit Main" << std::endl;
    return 0;
}

======= Test case end
Compilation:
gcc -O1 -o tst tst.cpp

Due to the bug the string "~Object()" will not be printed.

-- 
           Summary: exception throwing in virtual function doesn't turn on
                    the local destructors
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: critical
          Priority: P1
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: lassinovsky at algorithm dot aelita dot com
                CC: gcc-bugs at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2004-03-17 18:21 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-11 14:30 [Bug optimization/14535] New: exception throwing in virtual function doesn't turn on the local destructors lassinovsky at algorithm dot aelita dot com
2004-03-11 14:33 ` [Bug optimization/14535] " lassinovsky at algorithm dot aelita dot com
2004-03-11 16:05 ` [Bug optimization/14535] [3.3/3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
2004-03-11 16:19 ` bangerth at dealii dot org
2004-03-12  9:08 ` [Bug middle-end/14535] " rth at gcc dot gnu dot org
2004-03-12  9:36 ` rth at gcc dot gnu dot org
2004-03-12 13:44 ` lassinovsky at algorithm dot aelita dot com
2004-03-16  0:35 ` cvs-commit at gcc dot gnu dot org
2004-03-16  0:36 ` [Bug middle-end/14535] [3.3/3.4 " rth at gcc dot gnu dot org
2004-03-16  1:29 ` mark at codesourcery dot com
2004-03-16 21:05 ` cvs-commit at gcc dot gnu dot org
2004-03-17  3:12 ` mmitchel at gcc dot gnu dot org
2004-03-17 18:07 ` [Bug middle-end/14535] [3.3 " cvs-commit at gcc dot gnu dot org
2004-03-17 18:21 ` [Bug middle-end/14535] " rth at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).