Bug 58282 - g++.dg/tm/noexcept-1.C -fno-exceptions SIGSEGV in gimple_build_eh_must_not_throw
Summary: g++.dg/tm/noexcept-1.C -fno-exceptions SIGSEGV in gimple_build_eh_must_not_throw
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.9.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: EH, ice-on-valid-code, patch, trans-mem
Depends on:
Blocks:
 
Reported: 2013-08-30 15:26 UTC by Tom de Vries
Modified: 2013-10-25 14:36 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom de Vries 2013-08-30 15:26:38 UTC
$ arm-none-linux-gnueabi-g++ gcc/testsuite/g++.dg/tm/noexcept-1.C  -fno-diagnostics-show-caret -fdiagnostics-color=never   -fno-exceptions -fmessage-length=0  -fgnu-tm -O -std=c++0x -fdump-tree-tmmark -fdump-tree-tmlower  -S  -o noexcept-1.s
gcc/testsuite/g++.dg/tm/noexcept-1.C: In function 'int foo() [with T = TrueFalse]':^M
gcc/testsuite/g++.dg/tm/noexcept-1.C:13:43: internal compiler error: Segmentation fault^M
0x8951d05 crash_signal^M
        gcc/toplev.c:335^M
0x8707b50 gimple_build_eh_must_not_throw(tree_node*)^M
        gcc/gimple.c:730^M
0x8448b8a gimplify_must_not_throw_expr^M
        gcc/cp/cp-gimplify.c:503^M
0x844917a cp_gimplify_expr(tree_node**, gimple_statement_d**, gimple_statement_d**)^M
        gcc/cp/cp-gimplify.c:571^M
0x874de93 gimplify_expr(tree_node**, gimple_statement_d**, gimple_statement_d**, bool (*)(tree_node*), int)^M
        gcc/gimplify.c:7241^M
0x87470ba gimplify_stmt(tree_node**, gimple_statement_d**)^M
        gcc/gimplify.c:5699^M
0x87351b9 gimplify_bind_expr^M
        gcc/gimplify.c:1213^M
0x874eb0e gimplify_expr(tree_node**, gimple_statement_d**, gimple_statement_d**, bool (*)(tree_node*), int)^M
        gcc/gimplify.c:7493^M
0x87470ba gimplify_stmt(tree_node**, gimple_statement_d**)^M
        gcc/gimplify.c:5699^M
0x8732bfe gimplify_and_add(tree_node*, gimple_statement_d**)^M
        gcc/gimplify.c:329^M
0x8732c2d gimplify_and_return_first^M
        gcc/gimplify.c:341^M
0x874d8cf gimplify_transaction^M
        gcc/gimplify.c:7042^M
0x874fcb6 gimplify_expr(tree_node**, gimple_statement_d**, gimple_statement_d**, bool (*)(tree_node*), int)^M
        gcc/gimplify.c:7803^M
0x87470ba gimplify_stmt(tree_node**, gimple_statement_d**)^M
        gcc/gimplify.c:5699^M
0x87363fe gimplify_statement_list^M
        gcc/gimplify.c:1525^M
0x874f95d gimplify_expr(tree_node**, gimple_statement_d**, gimple_statement_d**, bool (*)(tree_node*), int)^M
        gcc/gimplify.c:7711^M
0x87470ba gimplify_stmt(tree_node**, gimple_statement_d**)^M
        gcc/gimplify.c:5699^M
0x8751d46 gimplify_body(tree_node*, bool)^M
        gcc/gimplify.c:8356^M
0x87524b2 gimplify_function_tree(tree_node*)^M
        gcc/gimplify.c:8488^M
0x8572c9a analyze_function^M
        gcc/cgraphunit.c:630^M
Please submit a full bug report,^M
with preprocessed source if appropriate.^M
Please include the complete backtrace with any bug report.^M
See <http://gcc.gnu.org/bugs.html> for instructions.^M
compiler exited with status 1
Comment 1 Tom de Vries 2013-08-30 15:29:02 UTC
svn revision 202105

Configured with: src/gcc-mainline/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-none-linux-gnueabi --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --with-gnu-as --with-gnu-ld --enable-languages=c,c++,fortran --enable-shared --enable-lto --enable-symvers=gnu --enable-__cxa_atexit --disable-nls --prefix=install --with-sysroot=install/arm-none-linux-gnueabi/libc --with-gmp=obj/pkg-mainline-0-arm-none-linux-gnueabi/fsf-mainline-0-arm-none-linux-gnueabi.extras/host-libs-i686-pc-linux-gnu/usr --with-mpfr=obj/pkg-mainline-0-arm-none-linux-gnueabi/fsf-mainline-0-arm-none-linux-gnueabi.extras/host-libs-i686-pc-linux-gnu/usr --with-mpc=obj/pkg-mainline-0-arm-none-linux-gnueabi/fsf-mainline-0-arm-none-linux-gnueabi.extras/host-libs-i686-pc-linux-gnu/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-isl=obj/pkg-mainline-0-arm-none-linux-gnueabi/fsf-mainline-0-arm-none-linux-gnueabi.extras/host-libs-i686-pc-linux-gnu/usr --with-cloog=obj/pkg-mainline-0-arm-none-linux-gnueabi/fsf-mainline-0-arm-none-linux-gnueabi.extras/host-libs-i686-pc-linux-gnu/usr --with-libelf=obj/pkg-mainline-0-arm-none-linux-gnueabi/fsf-mainline-0-arm-none-linux-gnueabi.extras/host-libs-i686-pc-linux-gnu/usr --disable-libgomp --disable-libitm --enable-poison-system-directories --with-build-time-tools=install/arm-none-linux-gnueabi/bin --with-build-time-tools=install/arm-none-linux-gnueabi/bin SED=sed
Comment 2 Tom de Vries 2013-08-30 15:47:34 UTC
It seems terminate_node is NULL
...
Program received signal SIGSEGV, Segmentation fault.
0x08707b50 in gimple_build_eh_must_not_throw (decl=0x0) at /home/vries/local/fsf_gcc_mainline_arm_none_linux_gnueabi/src/gcc-mainline/gcc/gimple.c:730
730       gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
(gdb) up
#1  0x08448b8b in gimplify_must_not_throw_expr (expr_p=0xf7dd8030, pre_p=0xffffc73c)
    at /home/vries/local/fsf_gcc_mainline_arm_none_linux_gnueabi/src/gcc-mainline/gcc/cp/cp-gimplify.c:503
503       mnt = gimple_build_eh_must_not_throw (terminate_node);
...
Comment 3 Tom de Vries 2013-08-30 16:26:46 UTC
also reproduces with x86_64
Comment 4 Tom de Vries 2013-09-02 10:31:25 UTC
Tentative fix:
...
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index ee3503c..c8b328c 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -5189,7 +5189,7 @@ finish_transaction_stmt (tree stmt, tree compound_stmt, int flags, tree noex)
 
   /* noexcept specifications are not allowed for function transactions.  */
   gcc_assert (!(noex && compound_stmt));
-  if (noex)
+  if (noex && flag_exceptions)
     {
       tree body = build_must_not_throw_expr (TRANSACTION_EXPR_BODY (stmt),
 					     noex);
@@ -5210,7 +5210,7 @@ tree
 build_transaction_expr (location_t loc, tree expr, int flags, tree noex)
 {
   tree ret;
-  if (noex)
+  if (noex && flag_exceptions)
     {
       expr = build_must_not_throw_expr (expr, noex);
       SET_EXPR_LOCATION (expr, loc);
...
Comment 6 Tom de Vries 2013-09-07 23:31:50 UTC
Author: vries
Date: Sat Sep  7 23:31:48 2013
New Revision: 202359

URL: http://gcc.gnu.org/viewcvs?rev=202359&root=gcc&view=rev
Log:
Handle noexcept on transactions with -fno-exceptions

2013-09-08  Tom de Vries  <tom@codesourcery.com>

	PR c++/58282
	* except.c (build_must_not_throw_expr): Handle
	flag_exceptions.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cp/except.c
Comment 7 Tom de Vries 2013-09-07 23:32:01 UTC
Author: vries
Date: Sat Sep  7 23:31:58 2013
New Revision: 202360

URL: http://gcc.gnu.org/viewcvs?rev=202360&root=gcc&view=rev
Log:
Testcase for PR58282

2013-09-08  Tom de Vries  <tom@codesourcery.com>

	PR c++/58282
	* g++.dg/tm/noexcept-6.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/tm/noexcept-6.C
Modified:
    trunk/gcc/testsuite/ChangeLog
Comment 8 Tom de Vries 2013-10-24 10:27:51 UTC
Also required for 4.7 and 4.8.
Comment 9 Tom de Vries 2013-10-25 13:49:51 UTC
Author: vries
Date: Fri Oct 25 13:49:48 2013
New Revision: 204067

URL: http://gcc.gnu.org/viewcvs?rev=204067&root=gcc&view=rev
Log:
2013-10-25  Tom de Vries  <tom@codesourcery.com>

	PR c++/58282
	* except.c (build_must_not_throw_expr): Handle
	flag_exceptions.

	* g++.dg/tm/noexcept-6.C: New test.

Added:
    branches/gcc-4_8-branch/gcc/testsuite/g++.dg/tm/noexcept-6.C
Modified:
    branches/gcc-4_8-branch/gcc/cp/ChangeLog
    branches/gcc-4_8-branch/gcc/cp/except.c
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
Comment 10 Tom de Vries 2013-10-25 14:20:09 UTC
Author: vries
Date: Fri Oct 25 14:20:06 2013
New Revision: 204069

URL: http://gcc.gnu.org/viewcvs?rev=204069&root=gcc&view=rev
Log:
2013-10-25  Tom de Vries  <tom@codesourcery.com>

	PR c++/58282
	* except.c (build_must_not_throw_expr): Handle
	flag_exceptions.

	* g++.dg/tm/noexcept-6.C: New test.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/g++.dg/tm/noexcept-6.C
Modified:
    branches/gcc-4_7-branch/gcc/cp/ChangeLog
    branches/gcc-4_7-branch/gcc/cp/except.c
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
Comment 11 Tom de Vries 2013-10-25 14:36:06 UTC
Fixed in trunk, and 4.7 and 4.8 branches.