The constant is only attached if the constexpr member is instantiated before the type is created in the DWARF.
We have solutions for type information that address these kinds of ordering problems (if we emit a declaration for a type, but later on that type is defined, we can emit that definition instead of the declaration we initially created) - it'd probably be good to do something similar for static constexpr members to reduce this kind of ordering dependence.
(huh, GCC doesn't produce any debug info for "m" in either case above... ( https://godbolt.org/z/z6sxPv6nf ) - I guess it only produces debug info if the variable has a real definition/storage is created for it... huh)
```
template<typename T>
struct t1 {
static constexpr bool m = sizeof(T) > 1;
};
t1<int> v1;
int i = t1<int>::m;
int j = t1<char>::m;
t1<char> v2;
```
Produces DWARF like this:
```
0x00000035: DW_TAG_variable
DW_AT_name ("m")
0x00000078: DW_TAG_variable
DW_AT_name ("m")
DW_AT_const_value (0)
```
The constant is only attached if the constexpr member is instantiated before the type is created in the DWARF.
We have solutions for type information that address these kinds of ordering problems (if we emit a declaration for a type, but later on that type is defined, we can emit that definition instead of the declaration we initially created) - it'd probably be good to do something similar for static constexpr members to reduce this kind of ordering dependence.
(huh, GCC doesn't produce any debug info for "m" in either case above... ( https://godbolt.org/z/z6sxPv6nf ) - I guess it only produces debug info if the variable has a real definition/storage is created for it... huh)
```
template<typename T>
struct t1 {
static constexpr bool m = sizeof(T) > 1;
};
t1<int> v1;
int i = t1<int>::m;
int j = t1<char>::m;
t1<char> v2;
```
Produces DWARF like this:
```
0x00000035: DW_TAG_variable
DW_AT_name ("m")
0x00000078: DW_TAG_variable
DW_AT_name ("m")
DW_AT_const_value (0)
```
The constant is only attached if the constexpr member is instantiated before the type is created in the DWARF.
We have solutions for type information that address these kinds of ordering problems (if we emit a declaration for a type, but later on that type is defined, we can emit that definition instead of the declaration we initially created) - it'd probably be good to do something similar for static constexpr members to reduce this kind of ordering dependence.
(huh, GCC doesn't produce any debug info for "m" in either case above... ( https://godbolt.org/z/z6sxPv6nf ) - I guess it only produces debug info if the variable has a real definition/storage is created for it... huh)
Produces DWARF like this:
The constant is only attached if the constexpr member is instantiated before the type is created in the DWARF.
We have solutions for type information that address these kinds of ordering problems (if we emit a declaration for a type, but later on that type is defined, we can emit that definition instead of the declaration we initially created) - it'd probably be good to do something similar for static constexpr members to reduce this kind of ordering dependence.
(huh, GCC doesn't produce any debug info for "m" in either case above... ( https://godbolt.org/z/z6sxPv6nf ) - I guess it only produces debug info if the variable has a real definition/storage is created for it... huh)