https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87364

--- Comment #5 from Will Wray <wjwray at gmail dot com> ---
re: https://gcc.gnu.org/ml/gcc/2018-02/msg00009.html
discussion on removing literal suffixes from Integral constants
(part a bigger conversation I'll pick up on below).

That change brought GCC into line with clang and MSVC which both
currently output plain digits with no distinguishing type info.
Unfortunately, plain digits output fails to distinguish non-type
template Args with same values but different Integral types.

To see how this discussion relates to enumeration constants
we must distinguish non-enumerated from enumerated values.

For non-enumerated values clang and MSVC output plain digits
while GCC outputs a C-style cast* (unchanged by this patch). 

For enumerated values the patch here brings GCC into line with
current clang and MSVC - all three now output enumerator ids*
(current MSVC outputs duplicate-value ids as-if non-enumerated).

(*ids and cast type are output with nested-specifier sequence.)

Clang & MSVC discussion
-----------------------
I started a thread with Clang devs about adding type info to enums:
__PRETTY_FUNCTION__ output loses enum type info for non-enumerated values
http://lists.llvm.org/pipermail/cfe-dev/2018-September/059229.html
(I also submitted a broader request to MSVC
https://developercommunity.visualstudio.com/content/problem/339663/improve-pretty-print-of-integral-non-type-template.html)

Richard Smith is open to the idea of Clang adding type info where needed.
He points out that the type info is only needed for deduced arguments,
which I interpret to mean 'auto' in C++17 but can be concept in C++20.
He singles out enum printing as a case where it may be OK to always print
the type, arguing that implicit conversion from integer is not allowed.

Mr Smith expanded the thread to cover -

General non-type template arguments: Integral constants and more
-----------------------------------
Picking up here on the bigger conversation, which really belongs elsewhere.
In the linked thread https://gcc.gnu.org/ml/gcc/2018-02/msg00030.html

Martin Sebor: 
  For auto, since it's new, a viable alternative might be to
  standardize the debug info format so that eventually all
  producers will converge on it. But even that approach won't
  help users of existing compilers.

C++20 generalises template non-type arguments to include LiteralType
https://en.cppreference.com/w/cpp/language/template_parameters
I doubt anyone considered yet what this means for debug info.
How do you pretty-print a general non-scalar non-type Arg constant?
Implementations will have to deal with this somehow (or ignore it).

Without consensus we'll get greater divergence.
This provides motivation NOW to discuss a general standard format.

While this is outside the remit of the C++ standards process
requirements for debug info / pretty-print should feed back to it.

For instance, it'd be useful for non-type Args to have a unique,
canonical constructor, akin to aggregate initialization perhaps.

Where best to pick up this discussion towards standard debug info?

Reply via email to