dwblaikie wrote:

Yes, the initializers do have to be lazyily evaluated to be a conforming C++ 
compiler.

eg: this code must compile without error so far as I understand:
```
template<int Value>
struct t1 {
  static constexpr int x = 3 / Value;
};
t1<0> v1;
```
Though it seems MSVC doesn't implement this correctly? 
https://godbolt.org/z/c1f6xKn3T

One way I've seen someone force the instantiation of the variable definition, 
and thus get the constant emitted into the DWARF, is using a static_assert:
```
template<int Value>
struct t1 {
  static constexpr int x = 3 / Value;
  static_assert(x, true);
};
t1<1> v1;
```
(of course, in this case, `t1<0>` can no longer be instantiated)

https://github.com/llvm/llvm-project/pull/95259
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to