re PR c++/80739 (Accessing value of X through a Y glvalue in a constant expression)
authorPaolo Carlini <paolo.carlini@oracle.com>
Fri, 27 Oct 2017 08:53:08 +0000 (08:53 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 27 Oct 2017 08:53:08 +0000 (08:53 +0000)
2017-10-27  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/80739
* g++.dg/cpp1y/constexpr-80739.C: New.

From-SVN: r254138

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/constexpr-80739.C [new file with mode: 0644]

index bafe8fd..57a8f44 100644 (file)
@@ -1,3 +1,8 @@
+2017-10-27  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/80739
+       * g++.dg/cpp1y/constexpr-80739.C: New.
+
 2017-10-27  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/81659
diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-80739.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-80739.C
new file mode 100644 (file)
index 0000000..5bfa082
--- /dev/null
@@ -0,0 +1,20 @@
+// PR c++/80739
+// { dg-do compile { target c++14 } }
+
+using size_t = decltype(sizeof(0));
+template <class T> struct element {
+    constexpr element() noexcept: x0(0), x1(0), x2(0), x3(0) {}
+    T x0; int x1, x2, x3;
+};
+template <class T> struct container {
+    constexpr container() noexcept: data() {data = element<T>();}
+    element<T> data;
+};
+template <class T> constexpr bool test() {
+    return (container<T>(), true);
+}
+int main() {
+    constexpr bool tmp0 = test<int>();
+    constexpr bool tmp1 = test<size_t>();
+    return tmp0 && tmp1;
+}