User account creation filtered due to spam.
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:
Date: Wed May 21 15:44:59 2014
New Revision: 210717
PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.
Add a new lang-hook that provides the underlying base type of an
ENUMERAL_TYPE. The default implementation will just use type_for_size.
The implementation for C++ will use the ENUM_UNDERLYING_TYPE if it exists.
Use this enum_underlying_base_type lang-hook in dwarf2out.c to add a
DW_AT_type base type reference to a DW_TAG_enumeration.
* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if DWARF
version >= 3 or not strict DWARF.
* langhooks.h (struct lang_hooks_for_types): Add
* langhooks.c (lhd_enum_underlying_base_type): New function.
* gcc/langhooks.h (struct lang_hooks_for_types): Add
* langhooks-def.h (lhd_enum_underlying_base_type): New declaration.
(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.
* cp-lang.c (cxx_enum_underlying_base_type): New function.
*** Bug 54774 has been marked as a duplicate of this bug. ***
So, is this fixed?
(In reply to Marek Polacek from comment #9)
> So, is this fixed?
Yes, I do believe so, in gcc trunk. Sorry for not closing earlier.