Bug 84752 - [8 Regression] ICE with constexpr array referenced in lambda
Summary: [8 Regression] ICE with constexpr array referenced in lambda
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.0
: P1 normal
Target Milestone: 8.0
Assignee: Jason Merrill
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2018-03-07 19:06 UTC by Volker Reichelt
Modified: 2018-03-10 03:38 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-03-07 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2018-03-07 19:06:30 UTC
The following valid code snippet triggers an ICE on trunk:

===============================
void foo()
{
  constexpr int x[1] = {};
  [&x]{ return (bool)x; };
}
===============================

bug.cc: In lambda function:
bug.cc:4:22: internal compiler error: in build_address, at cp/typeck.c:5744
   [&x]{ return (bool)x; };
                      ^
0x66a78b build_address(tree_node*)
	../../gcc/gcc/tree.h:3332
0x9dcaca cp_build_addr_expr_1
	../../gcc/gcc/cp/typeck.c:5974
0x9ddede cp_build_addr_expr(tree_node*, int)
	../../gcc/gcc/cp/typeck.c:6020
0x9ddede decay_conversion(tree_node*, int, bool)
	../../gcc/gcc/cp/typeck.c:2082
0x8236df convert_like_real
	../../gcc/gcc/cp/call.c:7087
0x823045 convert_like_real
	../../gcc/gcc/cp/call.c:6912
0x82cbe2 perform_direct_initialization_if_possible(tree_node*, tree_node*, bool, int)
	../../gcc/gcc/cp/call.c:10665
0x9e3b36 build_static_cast_1
	../../gcc/gcc/cp/typeck.c:7035
0x9e7dc7 cp_build_c_cast(tree_node*, tree_node*, int)
	../../gcc/gcc/cp/typeck.c:7796
0x9e807a build_c_cast(unsigned int, tree_node*, cp_expr)
	../../gcc/gcc/cp/typeck.c:7704
0x915d21 cp_parser_cast_expression
	../../gcc/gcc/cp/parser.c:9079
0x91628a cp_parser_binary_expression
	../../gcc/gcc/cp/parser.c:9191
0x917ac4 cp_parser_assignment_expression
	../../gcc/gcc/cp/parser.c:9486
0x9181d8 cp_parser_expression
	../../gcc/gcc/cp/parser.c:9655
0x920a26 cp_parser_jump_statement
	../../gcc/gcc/cp/parser.c:12415
0x920a26 cp_parser_statement
	../../gcc/gcc/cp/parser.c:10829
0x9217f0 cp_parser_statement_seq_opt
	../../gcc/gcc/cp/parser.c:11274
0x9222c7 cp_parser_lambda_body
	../../gcc/gcc/cp/parser.c:10685
0x9222c7 cp_parser_lambda_expression
	../../gcc/gcc/cp/parser.c:10186
0x9222c7 cp_parser_primary_expression
	../../gcc/gcc/cp/parser.c:5261
Please submit a full bug report, [etc.]

The regression was introduced between 2017-09-26 and 2017-10-07.
Comment 1 Jakub Jelinek 2018-03-07 19:18:26 UTC
Started with r253266.
Comment 2 Jason Merrill 2018-03-10 03:34:54 UTC
Author: jason
Date: Sat Mar 10 03:34:23 2018
New Revision: 258406

URL: https://gcc.gnu.org/viewcvs?rev=258406&root=gcc&view=rev
Log:
	PR c++/84752 - ICE with capture of constexpr array.

	* call.c (standard_conversion): Set rvaluedness_matches_p on the
	identity conversion under ck_lvalue.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-array3.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
Comment 3 Jason Merrill 2018-03-10 03:38:19 UTC
Fixed.