Bug 90526 - Missing DW_AT_const_value for constexpr field
Summary: Missing DW_AT_const_value for constexpr field
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-17 20:12 UTC by Tom Tromey
Modified: 2020-04-11 13:36 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Tromey 2019-05-17 20:12:07 UTC
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
Comment 1 Hannes Domani 2020-04-11 13:36:41 UTC
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;
}