public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/61611] New: Incorrect exception rethrown from a function-try-catch block when a nested try-catch executes
@ 2014-06-25 14:59 bspencer at blackberry dot com
2014-06-25 15:16 ` [Bug c++/61611] " redi at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: bspencer at blackberry dot com @ 2014-06-25 14:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61611
Bug ID: 61611
Summary: Incorrect exception rethrown from a function-try-catch
block when a nested try-catch executes
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: bspencer at blackberry dot com
Created attachment 33006
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33006&action=edit
Test program demonstrating the issue
In a try-catch (catch) block nested within, but separate from, a
function-try-catch (catch) block, gcc 4.7.2 for Linux (Debian) and gcc 4.8 for
Linux are both incorrectly re-throwing the exception caught inside the nested
catch block as that nested catch block exits.
Attached is a program that shows the error when compiled with -DFUNCTION_TRY
The program prints "PASS" when the correct exception propagates and and "FAIL"
when the incorrect exception propagates.
Note that this does not appear to be the behaviour of
15.3/15: "The currently handled exception is rethrown if control reaches the
end of a handler of the function-try-block of a constructor or destructor."
because the control is not reaching the end of such a handler. Thus, this
report differs from Bug #45481.
Perhaps _all_ catch blocks (including nested catch blocks) in a constructor
function try-catch are rethrowing when control reaches the end of them instead
of only the catch blocks of the actual constructor function try-catch
structure.
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.2-5'
--with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs
--enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.7 --enable-shared --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object
--enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.2 (Debian 4.7.2-5)
$ g++ -Wall -o test test.cc
$ ./test
main() starts
Caught out_of_range: out_of_range
Caught length_error: length_error
Re-throw original ex
TOP Caught out_of_range: out_of_range
PASS
main() stops
$ g++ -Wall -o test test.cc -DFUNCTION_TRY
$ ./test
main() starts
Caught out_of_range: out_of_range
Caught length_error: length_error
TOP Caught length_error: length_error
FAIL
main() stops
The attched program passes with clang++ (clang-503.0.40) with or without
-DFUNCTION_TRY.
Apologies for the non-preprocessed test file, but it does use only standard
headers.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/61611] Incorrect exception rethrown from a function-try-catch block when a nested try-catch executes
2014-06-25 14:59 [Bug c++/61611] New: Incorrect exception rethrown from a function-try-catch block when a nested try-catch executes bspencer at blackberry dot com
@ 2014-06-25 15:16 ` redi at gcc dot gnu.org
2022-01-06 14:42 ` jason at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2014-06-25 15:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61611
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-06-25
Ever confirmed|0 |1
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Brad Spencer from comment #0)
> Perhaps _all_ catch blocks (including nested catch blocks) in a constructor
> function try-catch are rethrowing when control reaches the end of them
> instead of only the catch blocks of the actual constructor function
> try-catch structure.
Yes, that seems to be the case.
> Apologies for the non-preprocessed test file, but it does use only standard
> headers.
That's fine, but personally I find it more useful if the testcase shows the bug
by default, and a macro is needed to make it pass.
Reduced:
struct A { };
struct B { };
class Test
{
public:
Test()
try
{
throw A();
}
catch(const A&)
{
try
{
throw B();
} catch(const B&) {
}
}
};
int
main()
{
try
{
Test x;
}
catch(const A&)
{
}
}
This should terminate normally.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/61611] Incorrect exception rethrown from a function-try-catch block when a nested try-catch executes
2014-06-25 14:59 [Bug c++/61611] New: Incorrect exception rethrown from a function-try-catch block when a nested try-catch executes bspencer at blackberry dot com
2014-06-25 15:16 ` [Bug c++/61611] " redi at gcc dot gnu.org
@ 2022-01-06 14:42 ` jason at gcc dot gnu.org
2022-01-07 0:26 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2022-01-06 14:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61611
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org
Status|NEW |ASSIGNED
CC| |jason at gcc dot gnu.org
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/61611] Incorrect exception rethrown from a function-try-catch block when a nested try-catch executes
2014-06-25 14:59 [Bug c++/61611] New: Incorrect exception rethrown from a function-try-catch block when a nested try-catch executes bspencer at blackberry dot com
2014-06-25 15:16 ` [Bug c++/61611] " redi at gcc dot gnu.org
2022-01-06 14:42 ` jason at gcc dot gnu.org
@ 2022-01-07 0:26 ` cvs-commit at gcc dot gnu.org
2022-01-07 0:32 ` jason at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-07 0:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61611
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:
https://gcc.gnu.org/g:6ad76e73375a9c00a0a5f5729ae70bce7a6db5bc
commit r12-6334-g6ad76e73375a9c00a0a5f5729ae70bce7a6db5bc
Author: Jason Merrill <jason@redhat.com>
Date: Thu Jan 6 09:45:26 2022 -0500
c++: nested catch in ctor fn-try-block [PR61611]
Being in_function_try_handler isn't enough to satisfy the condition of
reaching the end of such a handler; in this case, we're reaching the end of
a handler within that handler, so we don't want the special semantics.
PR c++/61611
gcc/cp/ChangeLog:
* except.c (in_nested_catch): New.
(expand_end_catch_block): Check it.
gcc/testsuite/ChangeLog:
* g++.dg/eh/ctor-fntry1.C: New test.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/61611] Incorrect exception rethrown from a function-try-catch block when a nested try-catch executes
2014-06-25 14:59 [Bug c++/61611] New: Incorrect exception rethrown from a function-try-catch block when a nested try-catch executes bspencer at blackberry dot com
` (2 preceding siblings ...)
2022-01-07 0:26 ` cvs-commit at gcc dot gnu.org
@ 2022-01-07 0:32 ` jason at gcc dot gnu.org
2022-01-28 4:38 ` cvs-commit at gcc dot gnu.org
2022-01-28 4:41 ` jason at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2022-01-07 0:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61611
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |12.0
Known to work| |12.0
--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for GCC 12 so far. Is there interest in having the fix in other release
branches?
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/61611] Incorrect exception rethrown from a function-try-catch block when a nested try-catch executes
2014-06-25 14:59 [Bug c++/61611] New: Incorrect exception rethrown from a function-try-catch block when a nested try-catch executes bspencer at blackberry dot com
` (3 preceding siblings ...)
2022-01-07 0:32 ` jason at gcc dot gnu.org
@ 2022-01-28 4:38 ` cvs-commit at gcc dot gnu.org
2022-01-28 4:41 ` jason at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-28 4:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61611
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:
https://gcc.gnu.org/g:cfcf6459810b010e8af2798581967872f68f1178
commit r11-9521-gcfcf6459810b010e8af2798581967872f68f1178
Author: Jason Merrill <jason@redhat.com>
Date: Thu Jan 6 09:45:26 2022 -0500
c++: nested catch in ctor fn-try-block [PR61611]
Being in_function_try_handler isn't enough to satisfy the condition of
reaching the end of such a handler; in this case, we're reaching the end of
a handler within that handler, so we don't want the special semantics.
PR c++/61611
gcc/cp/ChangeLog:
* except.c (in_nested_catch): New.
(expand_end_catch_block): Check it.
gcc/testsuite/ChangeLog:
* g++.dg/eh/ctor-fntry1.C: New test.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/61611] Incorrect exception rethrown from a function-try-catch block when a nested try-catch executes
2014-06-25 14:59 [Bug c++/61611] New: Incorrect exception rethrown from a function-try-catch block when a nested try-catch executes bspencer at blackberry dot com
` (4 preceding siblings ...)
2022-01-28 4:38 ` cvs-commit at gcc dot gnu.org
@ 2022-01-28 4:41 ` jason at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2022-01-28 4:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61611
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|12.0 |11.3
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 11.3/12.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-01-28 4:41 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-25 14:59 [Bug c++/61611] New: Incorrect exception rethrown from a function-try-catch block when a nested try-catch executes bspencer at blackberry dot com
2014-06-25 15:16 ` [Bug c++/61611] " redi at gcc dot gnu.org
2022-01-06 14:42 ` jason at gcc dot gnu.org
2022-01-07 0:26 ` cvs-commit at gcc dot gnu.org
2022-01-07 0:32 ` jason at gcc dot gnu.org
2022-01-28 4:38 ` cvs-commit at gcc dot gnu.org
2022-01-28 4:41 ` jason at gcc dot gnu.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).