Skip to content

Missing constant values in debug info for late-instantiated constexpr static members of class templates #102676

Open
@dwblaikie

Description

@dwblaikie
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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions