summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp0x/constexpr-array15.C
blob: a59e6f5df144b9b5fd2971f6e681cc4f6e0d847a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// PR c++/68949
// { dg-do run { target c++11 } }

struct Sub {
    int i;

    constexpr Sub() : i(-1) {} // remove constexpr and it works as expected
    Sub(Sub&& rhs); // remove this constructor and it works as epxected.
};

// v-- move this inline and it works as expected
// v-- remove ': Sub()' and it works as expected
Sub::Sub(Sub&& rhs) : Sub() { int tmp = i; i = rhs.i; rhs.i = tmp; }

struct Class {
    // v-- remove '[1]' and it works as expected
    // v-- add '= {}' and it works as expected
    Sub s[1];

    // v-- add ': s{}' and it works as expected
    // v-- removing this constructor makes it work as expected
    Class() {}
};

int main() {
    Class c;
    if (c.s[0].i != -1)
      __builtin_abort();
}