public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/5605: Wrong constructor is called when anonymous object is created in catch block.
@ 2002-09-15 11:58 nathan
0 siblings, 0 replies; 3+ messages in thread
From: nathan @ 2002-09-15 11:58 UTC (permalink / raw)
To: cs, gcc-bugs, gcc-prs, nobody
Synopsis: Wrong constructor is called when anonymous object is created in catch block.
State-Changed-From-To: open->analyzed
State-Changed-By: nathan
State-Changed-When: Sun Sep 15 11:58:05 2002
State-Changed-Why:
confirmed. Weird.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5605
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: c++/5605: Wrong constructor is called when anonymous object is created in catch block.
@ 2003-01-22 20:56 Wolfgang Bangerth
0 siblings, 0 replies; 3+ messages in thread
From: Wolfgang Bangerth @ 2003-01-22 20:56 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c++/5605; it has been noted by GNATS.
From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: gcc-bugs@gcc.gnu.org, <gcc-gnats@gcc.gnu.org>
Cc:
Subject: Re: c++/5605: Wrong constructor is called when anonymous object is
created in catch block.
Date: Wed, 22 Jan 2003 14:53:17 -0600 (CST)
This is actually a parser problem:
--------------------
struct A {
A();
A(int) {};
};
main() {
try { throw 666; }
catch (int & e) {
A (e); //***
}
}
-------------------------------
gcc parses the marked line as a declaration of variable e, and tries to
call the default constructor for A, which yields a linker error since
undefined. The submitter claims that this should rather create an unnamed
variable of type A, and run the constructor A::A(int) on it; since
defined, this would link properly.
icc7, by the way, says:
x.cc(9): error: "e" has already been declared in the current scope
A (e);
^
so applies the "this is a named variable" ethic too and spews an
additional error.
I don't know what is right or wrong here.
W.
-------------------------------------------------------------------------
Wolfgang Bangerth email: bangerth@ticam.utexas.edu
www: http://www.ticam.utexas.edu/~bangerth/
^ permalink raw reply [flat|nested] 3+ messages in thread
* c++/5605: Wrong constructor is called when anonymous object is created in catch block.
@ 2002-02-06 0:26 cs
0 siblings, 0 replies; 3+ messages in thread
From: cs @ 2002-02-06 0:26 UTC (permalink / raw)
To: gcc-gnats
>Number: 5605
>Category: c++
>Synopsis: Wrong constructor is called when anonymous object is created in catch block.
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Wed Feb 06 00:26:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: cs@plesk.com
>Release: at least 2.95.3 and 3.0.3
>Organization:
>Environment:
I'm sure it doesn't matter, at least on FreeBSD 4.3, 4.5 and RedHat 7.2 on i386.
>Description:
When executing a code like:
try {
// .....
} catch (SomeException &e) {
SomeClass(e);
}
will be called SomeClass::SomeClass() constructor instead of
SomeClass(SomeException) or something like.
>How-To-Repeat:
Just compile and run file attached. it outputs
A::A()
instead of
A::A(int)
>Fix:
Don't know
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="test.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test.cpp"
I2luY2x1ZGUgPHN0ZGlvLmg+CmNsYXNzIEEgewpwdWJsaWM6CglBKCkKCXsKCQlwcmludGYoIiVz
XG4iLCBfX1BSRVRUWV9GVU5DVElPTl9fKTsKCX0KCUEoaW50KQoJewoJCXByaW50ZigiJXNcbiIs
IF9fUFJFVFRZX0ZVTkNUSU9OX18pOwoJfQp9OwoKbWFpbigpCnsKCXRyeSB7CgkJdGhyb3cgNjY2
OwoJfSBjYXRjaCAoaW50ICYgZSkgewoJCUEgKGUpOwoJfQp9Cg==
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-01-22 20:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-15 11:58 c++/5605: Wrong constructor is called when anonymous object is created in catch block nathan
-- strict thread matches above, loose matches on Subject: below --
2003-01-22 20:56 Wolfgang Bangerth
2002-02-06 0:26 cs
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).