re PR c++/48324 ([C++0x] constexpr evaluation should respect lifetime rules)
authorPaolo Carlini <paolo.carlini@oracle.com>
Fri, 20 Mar 2015 17:26:32 +0000 (17:26 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 20 Mar 2015 17:26:32 +0000 (17:26 +0000)
2015-03-20  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/48324
* g++.dg/cpp0x/constexpr-48324.C: New.

From-SVN: r221539

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

index 585c9123f6435a04cd6faa309983f70823edfe48..9e55738cedb2bd8f45a261142d8dcaaf3e56495d 100644 (file)
@@ -1,3 +1,8 @@
+2015-03-20  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/48324
+       * g++.dg/cpp0x/constexpr-48324.C: New.
+
 2015-03-20  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/48453
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-48324.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-48324.C
new file mode 100644 (file)
index 0000000..cef464c
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/48324
+// { dg-do compile { target c++11 } }
+
+struct S {
+  const int val;
+  constexpr S(int i) : val(i) { }
+};
+
+constexpr const int& to_ref(int i) {
+  return S(i).val; // { dg-warning "reference to temporary" }
+}
+
+constexpr int ary[to_ref(98)] = { }; // { dg-error "not an integral" }