From e251e8157e03185147aae03265bae837a54042a5 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Fri, 20 Mar 2015 17:26:32 +0000 Subject: [PATCH] re PR c++/48324 ([C++0x] constexpr evaluation should respect lifetime rules) 2015-03-20 Paolo Carlini PR c++/48324 * g++.dg/cpp0x/constexpr-48324.C: New. From-SVN: r221539 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/constexpr-48324.C | 13 +++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/constexpr-48324.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 585c9123f64..9e55738cedb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-03-20 Paolo Carlini + + PR c++/48324 + * g++.dg/cpp0x/constexpr-48324.C: New. + 2015-03-20 Paolo Carlini 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 index 00000000000..cef464cf9b8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-48324.C @@ -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" } -- 2.30.2