[Dwarf-Discuss] Inconsistency of C++ member function qualifiers

David Blaikie dblaikie at gmail.com
Tue Oct 5 12:12:26 PDT 2021


C++ member functions can be qualified in a number of ways - classic CV
(const and volatile) qualifiers, and since C++11, lvalue (&) and rvalue
(&&) reference qualifiers. Details here:
https://en.cppreference.com/w/cpp/language/member_functions

A note on 5.10, page 127 says:

"C++ const-volatile qualifiers are encoded as part of the type of the
“this”-pointer. C++11 reference and rvalue-reference qualifiers are encoded
using the DW_AT_reference and DW_AT_rvalue_reference attributes,
respectively. See also Section 5.7.8 on page 120."

Though this appears to be inadequate, because C++ allows these qualifiers
on any function type - even one without a first parameter necessary to
carry the const/volatile qualifiers.

eg:
template<typename T>
struct t1 { };
t1<void () const> v1;

GCC implements this type by using DW_TAG_const_type around a
DW_TAG_subroutine_type. I've implemented the same behavior in Clang
recently.

For actual member functions (eg: void (some_type::*)() const) both Clang
and GCC put the const type on the artificial first parameter rather than by
wrapping the type in DW_TAG_const_type.


Does this seem acceptable, should we do something different to unify the
representation between these two cases? Should we add some more
non-normative text in 5.10/p127?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dwarfstd.org/pipermail/dwarf-discuss-dwarfstd.org/attachments/20211005/d287148a/attachment.html>


More information about the Dwarf-Discuss mailing list