From: Paolo Carlini Date: Mon, 19 Jun 2017 10:15:57 +0000 (+0000) Subject: re PR c++/66093 (g++ produces incorrect output on code with constexpr function initia... X-Git-Tag: upstream/12.2.0~38712 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=431abe69f1c4ba0b4b05609f2f4f9206cc6e041a;p=platform%2Fupstream%2Fgcc.git re PR c++/66093 (g++ produces incorrect output on code with constexpr function initializing class with private fields) 2017-06-19 Paolo Carlini PR c++/66093 * g++.dg/cpp1y/constexpr-66093.C: New. From-SVN: r249364 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8153a71..f879c10 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-06-19 Paolo Carlini + + PR c++/66093 + * g++.dg/cpp1y/constexpr-66093.C: New. + 2017-06-19 Rainer Orth * g++.dg/other/unused1.C: Remove *-*-solaris2.[56]* from diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-66093.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-66093.C new file mode 100644 index 0000000..ad31692 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-66093.C @@ -0,0 +1,35 @@ +// { dg-do run { target c++14 } } + +#include + +constexpr int n = 10; + +struct A { + constexpr operator const int*() const { + return data; + } + + constexpr operator int*() { + return data; + } + +private: + int data[n]; +}; + +constexpr A f() { + A a{}; + for (int i = 1; i <= n; i++) { + a[i] = i; + } + return a; +} + +A a = f(); + +int main() +{ + for (int i = 0; i < n; i++) { + assert (a[i] == i); + } +}