repo.or.cz
/
official-gcc.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
PR c++/56973, DR 696 - capture constant variables only as needed.
[official-gcc.git]
/
gcc
/
testsuite
/
g++.dg
/
cpp1y
/
constexpr-66093.C
blob
ad3169210d29a41137f51aceea5516a6c042cb3c
1
// { dg-do run { target c++14 } }
2
3
#include <cassert>
4
5
constexpr int n = 10;
6
7
struct A {
8
constexpr operator const int*() const {
9
return data;
10
}
11
12
constexpr operator int*() {
13
return data;
14
}
15
16
private:
17
int data[n];
18
};
19
20
constexpr A f() {
21
A a{};
22
for (int i = 1; i <= n; i++) {
23
a[i] = i;
24
}
25
return a;
26
}
27
28
A a = f();
29
30
int main()
31
{
32
for (int i = 0; i < n; i++) {
33
assert (a[i] == i);
34
}
35
}