Bug 88701 - [9 Regression] Internal compiler error for valid program using compound literal with variably modified type.
Summary: [9 Regression] Internal compiler error for valid program using compound liter...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 9.0
: P1 normal
Target Milestone: 9.0
Assignee: Jakub Jelinek
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2019-01-04 22:48 UTC by Anders Granlund
Modified: 2019-01-08 15:19 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2019-01-04 00:00:00


Attachments
gcc9-pr88701.patch (497 bytes, patch)
2019-01-07 12:43 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Anders Granlund 2019-01-04 22:48:44 UTC
Test case (prog.c):

  void f(int [(int (*)[*]) { 0 } == 0]);

  int main()
  {
  }

Compilation command line:

  gcc prog.c -Wall -Wextra -std=c11 -pedantic-errors

Observed behaviour:

  Internal compiler error.
Comment 1 Anders Granlund 2019-01-04 23:03:40 UTC
Another test case that also gives internal compiler error with the same compilation command line:

  void f(int n, int [(int (*)[n]) { 0 } == 0]);

  int main()
  {
  }
Comment 2 Joseph S. Myers 2019-01-04 23:29:28 UTC
Does not appear with GCC 8 branch, so a regression, can someone bisect to find what commit introduced this ICE?

internal compiler error: in get_parm_info, at c/c-decl.c:7517
0x5992b3 get_parm_info(bool, tree_node*)
        /scratch/jmyers/fsf/gcc-mainline/gcc/c/c-decl.c:7517
0x7e92e7 c_parser_parms_list_declarator
        /scratch/jmyers/fsf/gcc-mainline/gcc/c/c-parser.c:4024
0x7e9403 c_parser_parms_declarator
        /scratch/jmyers/fsf/gcc-mainline/gcc/c/c-parser.c:3939
0x7e2ae9 c_parser_direct_declarator_inner
        /scratch/jmyers/fsf/gcc-mainline/gcc/c/c-parser.c:3868
0x7f8ead c_parser_declaration_or_fndef
        /scratch/jmyers/fsf/gcc-mainline/gcc/c/c-parser.c:1999
0x800bef c_parser_external_declaration
        /scratch/jmyers/fsf/gcc-mainline/gcc/c/c-parser.c:1653
0x801611 c_parser_translation_unit
        /scratch/jmyers/fsf/gcc-mainline/gcc/c/c-parser.c:1534
0x801611 c_parse_file()
        /scratch/jmyers/fsf/gcc-mainline/gcc/c/c-parser.c:19807
0x853afb c_common_parse_file()
        /scratch/jmyers/fsf/gcc-mainline/gcc/c-family/c-opts.c:1151
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Comment 3 Marek Polacek 2019-01-04 23:36:44 UTC
Started with r259641.
Comment 4 Anders Granlund 2019-01-04 23:38:29 UTC
Thanks for the bisect.
Comment 5 Jakub Jelinek 2019-01-07 12:43:21 UTC
Created attachment 45366 [details]
gcc9-pr88701.patch

For what I wanted to achieve with that change (i.e. put the compound literal decls in the block scope they belong to), the following works too; it is fine if the compound literals in the function parameters are handled as before - in the scope of the function.
Comment 6 Jakub Jelinek 2019-01-07 22:56:19 UTC
Author: jakub
Date: Mon Jan  7 22:55:48 2019
New Revision: 267667

URL: https://gcc.gnu.org/viewcvs?rev=267667&root=gcc&view=rev
Log:
	PR c/88701
	* c-decl.c (build_compound_literal): If not TREE_STATIC, only pushdecl
	if current_function_decl is non-NULL.

	* gcc.dg/pr88701.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/pr88701.c
Modified:
    trunk/gcc/c/ChangeLog
    trunk/gcc/c/c-decl.c
    trunk/gcc/testsuite/ChangeLog
Comment 7 Jakub Jelinek 2019-01-08 15:19:53 UTC
Fixed.