GCC Bugzilla – Bug 16063
Debuggers need more information about enum types in C++
Last modified: 2014-03-23 11:22:24 UTC
The debug information emitted for enumerated types does not allow a debugger
to unambiguously determine the "underlying type" of the enumeration.
A debugger therefore does not have enough information to allow it to perform
overload resolution when asked to evaluate a function call with an enum type
as an actual argument.
One can view this either as a bug (the compiler is emitting an unsigned value
using DW_FORM_sdata), or as requiring an enhancement.
I believe the simplest solution would be to have the compiler be explicit about
the representation of the enum type by emitting a DW_AT_encoding with the
DW_TAG_enumeration, so that the debugger is explicitly told whether the
underlying type of the enumeration is signed or unsigned.
See the (about to be attached) test case for detailed information.
Created attachment 6565 [details]
Test case with embedded description.
Confirmed, I should note that ICC 6.0 does not do this also.
Created attachment 6566 [details]
Patch against 3.4.0
This simple patch does everything we need, I believe.
Subject: Re: Debuggers need more information about enum types in C++
> Confirmed, I should note that ICC 6.0 does not do this also.
Right, it's an extension to the DWARF standard to require this.
I have submitted changes to add this to DWARF to the DWARF2 maliing
lists, but have yet to receive feedback.
I have also submitted it as a bug report to Intel against their latest
I imagine their fix may take longer than yours if you're happy with
the (one line of code) patch which I just submitted.
DWARF 4 allows this:
The enumeration type entry may have a DW_AT_type attribute which refers to the underlying
data type used to implement the enumeration.
I think this is definitely needed for "enum class", where the base
type can be specified by the user.
However, emitting it unconditionally wouldn't hurt.
Posted a patch: