[clang] [Clang][Driver] Expose `-fno-eliminate-unused-debug-types` to clang-cl (PR #95259)

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 22 11:56:02 PDT 2024


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


More information about the cfe-commits mailing list