-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patha.cpp
44 lines (39 loc) · 1002 Bytes
/
a.cpp
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright Glen Knowles 2018.
// Distributed under the Boost Software License, Version 1.0.
//
// a.cpp - bugs msvc2017-5
//
// Compile with: Visual C++ 2017 Version 15.7.3
// (This is not a problem with 2017 15.7.2)
//
// error C2131: expression did not evaluate to a constant
// note: failure was caused by control reaching the end of a constexpr function
// note: see reference to class template instantiation 'Buffer<double>' being
// compiled
// fatal error C1060: compiler is out of heap space
#define FAILING 1
constexpr int table_value() {
const unsigned kTable[] = { 1, 2 };
#if FAILING
// 15.7.2 - works
// 15.7.3 - fails with C2131 error
int r = kTable[0];
return r;
#else
// works in both 2017 15.7.2 and 15.7.3
return kTable[0]
#endif
}
template <typename T> constexpr
int bufLen() {
return table_value();
}
template <typename T>
struct Buffer {
char data[bufLen<T>() + 1];
};
int main() {
Buffer<double> tmp;
tmp = {};
return 0;
}