re PR c++/66093 (g++ produces incorrect output on code with constexpr function initializing class with private fields)
2017-06-19 Paolo Carlini <paolo.carlini@oracle.com> PR c++/66093 * g++.dg/cpp1y/constexpr-66093.C: New. From-SVN: r249364
This commit is contained in:
parent
a06a538548
commit
431abe69f1
@ -1,3 +1,8 @@
|
||||
2017-06-19 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
PR c++/66093
|
||||
* g++.dg/cpp1y/constexpr-66093.C: New.
|
||||
|
||||
2017-06-19 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
|
||||
|
||||
* g++.dg/other/unused1.C: Remove *-*-solaris2.[56]* from
|
||||
|
35
gcc/testsuite/g++.dg/cpp1y/constexpr-66093.C
Normal file
35
gcc/testsuite/g++.dg/cpp1y/constexpr-66093.C
Normal file
@ -0,0 +1,35 @@
|
||||
// { dg-do run { target c++14 } }
|
||||
|
||||
#include <cassert>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user