Bug 71494 - [4.9 Regression] label as value in nested function
Summary: [4.9 Regression] label as value in nested function
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 6.1.1
: P3 normal
Target Milestone: 7.0
Assignee: Jakub Jelinek
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2016-06-10 09:30 UTC by Mikhail Osipov
Modified: 2016-07-08 07:22 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work: 4.3.6
Known to fail: 4.4.7
Last reconfirmed: 2016-06-10 00:00:00


Attachments
sample source (108 bytes, text/plain)
2016-06-10 09:30 UTC, Mikhail Osipov
Details
gcc7-pr71494.patch (551 bytes, patch)
2016-06-10 12:03 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mikhail Osipov 2016-06-10 09:30:49 UTC
Created attachment 38676 [details]
sample source

"goto *label" leads to the internal compiler error when used in nested function

$ gcc main.c
main.c: In function ‘test’:
main.c:7:3: internal compiler error: in expand_expr_real_1, at expr.c:9651
   goto *label;
   ^~~~
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://bugs.archlinux.org/> for instructions.
Comment 1 Richard Biener 2016-06-10 09:44:38 UTC
Confirmed.
Comment 2 Jakub Jelinek 2016-06-10 12:03:17 UTC
Created attachment 38680 [details]
gcc7-pr71494.patch

Your testcase is IMNSHO invalid, you can't combine non-local goto with computed goto together, there is either computed goto, which can branch only to labels in the same function, or non-local goto, which needs to have a non-local label as goto operand, not *expression.  But, I've changed it into a valid testcase.
And with the fix even the invalid testcase doesn't ICE anymore.
Comment 3 Jakub Jelinek 2016-06-10 19:49:37 UTC
Author: jakub
Date: Fri Jun 10 19:49:05 2016
New Revision: 237317

URL: https://gcc.gnu.org/viewcvs?rev=237317&root=gcc&view=rev
Log:
	PR middle-end/71494
	* tree-nested.c (convert_nonlocal_reference_stmt): For GIMPLE_GOTO
	without LABEL_DECL, set *handled_ops_p to false instead of true.

	* gcc.c-torture/execute/pr71494.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/pr71494.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-nested.c
Comment 4 Jakub Jelinek 2016-06-14 14:46:00 UTC
Author: jakub
Date: Tue Jun 14 14:45:23 2016
New Revision: 237449

URL: https://gcc.gnu.org/viewcvs?rev=237449&root=gcc&view=rev
Log:
	Backported from mainline
	2016-06-10  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/71494
	* tree-nested.c (convert_nonlocal_reference_stmt): For GIMPLE_GOTO
	without LABEL_DECL, set *handled_ops_p to false instead of true.

	* gcc.c-torture/execute/pr71494.c: New test.

Added:
    branches/gcc-6-branch/gcc/testsuite/gcc.c-torture/execute/pr71494.c
Modified:
    branches/gcc-6-branch/gcc/ChangeLog
    branches/gcc-6-branch/gcc/testsuite/ChangeLog
    branches/gcc-6-branch/gcc/tree-nested.c
Comment 5 Jakub Jelinek 2016-06-14 14:52:54 UTC
Fixed for 6.2+ so far.
Comment 6 Jakub Jelinek 2016-07-07 12:44:22 UTC
Author: jakub
Date: Thu Jul  7 12:43:50 2016
New Revision: 238096

URL: https://gcc.gnu.org/viewcvs?rev=238096&root=gcc&view=rev
Log:
	Backported from mainline
	2016-06-10  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/71494
	* tree-nested.c (convert_nonlocal_reference_stmt): For GIMPLE_GOTO
	without LABEL_DECL, set *handled_ops_p to false instead of true.

	* gcc.c-torture/execute/pr71494.c: New test.

Added:
    branches/gcc-5-branch/gcc/testsuite/gcc.c-torture/execute/pr71494.c
Modified:
    branches/gcc-5-branch/gcc/ChangeLog
    branches/gcc-5-branch/gcc/testsuite/ChangeLog
    branches/gcc-5-branch/gcc/tree-nested.c
Comment 7 Jakub Jelinek 2016-07-07 13:18:26 UTC
Fixed also for 5.5+.
Comment 8 Jakub Jelinek 2016-07-07 21:52:29 UTC
Author: jakub
Date: Thu Jul  7 21:51:57 2016
New Revision: 238143

URL: https://gcc.gnu.org/viewcvs?rev=238143&root=gcc&view=rev
Log:
	Backported from mainline
	2016-06-10  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/71494
	* tree-nested.c (convert_nonlocal_reference_stmt): For GIMPLE_GOTO
	without LABEL_DECL, set *handled_ops_p to false instead of true.

	* gcc.c-torture/execute/pr71494.c: New test.

Added:
    branches/gcc-4_9-branch/gcc/testsuite/gcc.c-torture/execute/pr71494.c
Modified:
    branches/gcc-4_9-branch/gcc/ChangeLog
    branches/gcc-4_9-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_9-branch/gcc/tree-nested.c
Comment 9 Jakub Jelinek 2016-07-08 07:22:30 UTC
Fixed.