* C++ PATCH for c++/84752, ICE with capture of constexpr array
@ 2018-03-10 3:33 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2018-03-10 3:33 UTC (permalink / raw)
To: gcc-patches List
[-- Attachment #1: Type: text/plain, Size: 217 bytes --]
Another case where we need to set a flag on the ck_identity conversion
so that we don't mistakenly pull out the constant value of something
that we want the address of.
Tested x86_64-pc-linux-gnu, applying to trunk.
[-- Attachment #2: 84752.diff --]
[-- Type: text/x-patch, Size: 1732 bytes --]
commit 493898f505c4b38145356ef3b51dd986312497a8
Author: Jason Merrill <jason@redhat.com>
Date: Fri Mar 9 17:14:04 2018 -0500
PR c++/84752 - ICE with capture of constexpr array.
* call.c (standard_conversion): Set rvaluedness_matches_p on the
identity conversion under ck_lvalue.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 17cd1c4f63e..45c22aaa312 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -103,7 +103,7 @@ struct conversion {
being bound to an rvalue expression. If KIND is ck_rvalue,
true when we are treating an lvalue as an rvalue (12.8p33). If
KIND is ck_base, always false. If ck_identity, we will be
- binding a reference directly. */
+ binding a reference directly or decaying to a pointer. */
BOOL_BITFIELD rvaluedness_matches_p: 1;
BOOL_BITFIELD check_narrowing: 1;
/* The type of the expression resulting from the conversion. */
@@ -1139,6 +1139,8 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p,
{
from = type_decays_to (from);
fcode = TREE_CODE (from);
+ /* Tell convert_like_real that we're using the address. */
+ conv->rvaluedness_matches_p = true;
conv = build_conv (ck_lvalue, from, conv);
}
/* Wrapping a ck_rvalue around a class prvalue (as a result of using
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-array3.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-array3.C
new file mode 100644
index 00000000000..09711033511
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-array3.C
@@ -0,0 +1,9 @@
+// PR c++/84752
+// { dg-do compile { target c++11 } }
+
+void foo()
+{
+ constexpr int x[1] = {};
+ [&x]{ return (bool)x; };
+}
+
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-03-10 3:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-10 3:33 C++ PATCH for c++/84752, ICE with capture of constexpr array Jason Merrill
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).