From 355229f22a06073a288f6da189ea2757c5e09e30 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Thu, 8 Aug 2019 17:54:58 +0000 Subject: [PATCH] re PR c++/79520 (Spurious caching for constexpr arguments) PR c++/79520 * g++.dg/cpp1y/constexpr-79520.C: New test. From-SVN: r274214 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp1y/constexpr-79520.C | 11 +++++++++++ 2 files changed, 16 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-79520.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a9f6c54aa84..c44e3795099 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-08-08 Marek Polacek + + PR c++/79520 + * g++.dg/cpp1y/constexpr-79520.C: New test. + 2019-08-08 Richard Sandiford * gcc.dg/pr79983.c (enum E): Don't allow an error about nested diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-79520.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-79520.C new file mode 100644 index 00000000000..a53bb3e711e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-79520.C @@ -0,0 +1,11 @@ +// PR c++/79520 +// { dg-do compile { target c++14 } } + +constexpr int f(int const& x) { return x; } + +constexpr struct S { + int x = 0; + constexpr S() {(void)f(x); x = 1;} +} s; + +static_assert(f(s.x) == 1, ""); -- 2.30.2