* [pushed] c++: member alias declaration [PR103968]
@ 2022-03-28 13:33 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2022-03-28 13:33 UTC (permalink / raw)
To: gcc-patches
Here, we were wrongly thinking that (const Options&)Widget<T>::c_options is
not value-dependent because neither the type nor the (value of) c_options
are dependent, but since we're binding it to a reference we also need to
consider that it has a value-dependent address.
Tested x86_64-pc-linux-gnu, applying to trunk.
PR c++/103968
gcc/cp/ChangeLog:
* pt.cc (value_dependent_expression_p): Check
has_value_dependent_address for conversion to reference.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/alias-decl-mem1.C: New test.
---
gcc/cp/pt.cc | 4 ++++
gcc/testsuite/g++.dg/cpp0x/alias-decl-mem1.C | 20 ++++++++++++++++++++
2 files changed, 24 insertions(+)
create mode 100644 gcc/testsuite/g++.dg/cpp0x/alias-decl-mem1.C
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 2738c20dafa..8c1fb864278 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -27482,6 +27482,10 @@ value_dependent_expression_p (tree expression)
if (TREE_CODE (expression) == TREE_LIST)
return any_value_dependent_elements_p (expression);
+ if (TREE_CODE (type) == REFERENCE_TYPE
+ && has_value_dependent_address (expression))
+ return true;
+
return value_dependent_expression_p (expression);
}
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-mem1.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-mem1.C
new file mode 100644
index 00000000000..3e422de4054
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-mem1.C
@@ -0,0 +1,20 @@
+// PR c++/103968
+// { dg-do compile { target c++11 } }
+
+template <typename Opt, Opt const& options>
+struct trait
+{
+ template <typename T>
+ struct NonInstantiated{};
+};
+
+struct Options {};
+
+template <typename T>
+struct Widget
+{
+ static constexpr auto c_options = Options{};
+ using Trait = trait<decltype(c_options), c_options>;
+};
+
+Widget<int>::Trait b{}; // Crashes GCC > 10.3
base-commit: bc86a86a4f2c057bc0e0be94dcbb8c128ae7f717
prerequisite-patch-id: 09e711b54e7911a4a04bd7808abc1b73ae4482ba
prerequisite-patch-id: 566cf0772894d0c6a842b2e0ca62eb1d5ae8ad33
prerequisite-patch-id: b1def7e83e76c1652efb483cb2b67e472d15b720
prerequisite-patch-id: 12973b1310781ff6ce5c9792ea689f0673fc5251
prerequisite-patch-id: 8dcc4ecc29dbe7b290325412af70613171456714
--
2.27.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-03-28 13:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-28 13:33 [pushed] c++: member alias declaration [PR103968] 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).