public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11069] New: C++ Standard Violation (15.3.3)
@ 2003-06-02 21:56 afu@fugmann.dhs.org
  2003-06-02 22:23 ` [Bug c++/11069] " bangerth@dealii.org
  0 siblings, 1 reply; 2+ messages in thread
From: afu@fugmann.dhs.org @ 2003-06-02 21:56 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: C++ Standard Violation (15.3.3)
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: major
          Priority: P2
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: afu@fugmann.dhs.org
                CC: gcc-bugs@gcc.gnu.org

When thowing an object it seems that the type of the variable thrown is used and
not the type of the object thrown in the catch block. This menas that exception
are not caught correctly, and that it is impossible to destruct the thrown
object correctly.

To reproduce the bug, compile and run the following program:
#include <iostream>
using namespace std;

class Exception
{
public:
    Exception() {
	cout << "Constructor called" << endl;
    }
    
    virtual ~Exception() {
	cout << "Destructor called" << endl;
    }    
};

class ExtendedException: public Exception
{  
public:
    ExtendedException(): Exception() {
	cout << "EE Constructor called" << endl;
    }
    
    ~ExtendedException() {
	cout << "EE Destructor called" << endl;
    }
};

int main()
{
    try {
	Exception *e = new ExtendedException();
	throw (*e);
    } 
    catch (ExtendedException &ee) {
	cout << "Caught ExtendedException" << endl;
    }
    
    catch (Exception &e) {
	cout << "Caught Exception" << endl;
    }
}

Expected result:
 Constructor called
 EE Constructor called
 Caught ExtendedException
 EE Destructor called
 Destructor called

Got result:
 Constructor called
 EE Constructor called
 Caught Exception
 Destructor called

Changing the type of *e to ExtendedException produces the expected result.



------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug c++/11069] C++ Standard Violation (15.3.3)
  2003-06-02 21:56 [Bug c++/11069] New: C++ Standard Violation (15.3.3) afu@fugmann.dhs.org
@ 2003-06-02 22:23 ` bangerth@dealii.org
  0 siblings, 0 replies; 2+ messages in thread
From: bangerth@dealii.org @ 2003-06-02 22:23 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


bangerth@dealii.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID
            Summary|C++ Standard Violation      |C++ Standard Violation
                   |(15.3.3)                    |(15.3.3)


------- Additional Comments From bangerth@dealii.org  2003-06-02 22:23 -------
Not a bug. 15.1.3 says:
3 A throw-expression initializes a temporary object, the type  of  which
  is  determined by removing any top-level cv-qualifiers from the static
  type of the operand of throw and adjusting the type from "array of  T"
  or  "function  returning  T" to "pointer to T" or "pointer to function
  returning T", respectively.

Not that it is talking about the _static_ type, not the dynamic type.
Matching of exception handlers is done against this _static_ type.

W.



------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

end of thread, other threads:[~2003-06-02 22:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-02 21:56 [Bug c++/11069] New: C++ Standard Violation (15.3.3) afu@fugmann.dhs.org
2003-06-02 22:23 ` [Bug c++/11069] " bangerth@dealii.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).