gcc/testsuite/g++.dg/cpp0x/constexpr-ptrsub.C
raw| 1 | // PR c++/51489 |
| 2 | // DR 1313 |
| 3 | // { dg-do compile { target c++11 } } |
| 4 | |
| 5 | struct array |
| 6 | { |
| 7 | constexpr array() :x(0) {} |
| 8 | constexpr int const* begin() const { return &x; } |
| 9 | int x; |
| 10 | }; |
| 11 | constexpr array aa; |
| 12 | constexpr auto b = aa.begin(); |
| 13 | static_assert(b-b == 0, "compiles just fine"); |
| 14 | static_assert(aa.begin()-aa.begin() == 0, "compiler thinks it's not a constant expression"); |