This test case comes from https://sourceware.org/bugzilla/show_bug.cgi?id=20020 Consider: template<typename _Tp> struct foo { static constexpr bool is_always_lock_free = true; }; int main() { foo<int> p; return 0; } Using a recent trunk gcc: gcc (GCC) 10.0.0 20190515 (experimental), compiling with -g, and looking at the DWARF, I see this DIE for foo<int>::is_always_lock_free: <2><3a>: Abbrev Number: 3 (DW_TAG_member) <3b> DW_AT_name : (indirect string, offset: 0x0): is_always_lock_free <3f> DW_AT_decl_file : 1 <40> DW_AT_decl_line : 4 <41> DW_AT_decl_column : 25 <42> DW_AT_type : <0x57> <46> DW_AT_external : 1 <46> DW_AT_declaration : 1 <46> DW_AT_const_expr : 1 Notice no DW_AT_const_value. However, I change foo to not be a template, I get: <2><3a>: Abbrev Number: 3 (DW_TAG_member) <3b> DW_AT_name : (indirect string, offset: 0x15): is_always_lock_free <3f> DW_AT_decl_file : 1 <40> DW_AT_decl_line : 3 <41> DW_AT_decl_column : 25 <42> DW_AT_type : <0x4f> <46> DW_AT_external : 1 <46> DW_AT_declaration : 1 <46> DW_AT_const_value : 1 <47> DW_AT_const_expr : 1 I think the template case should also emit a const_value
The DW_AT_const_value is also emitted if the variable is used, like: int main() { foo<int> p; return !p.is_always_lock_free; }