Skip to content

Improve std::source_location::function_name() informativeness #3063

@b1ackviking

Description

@b1ackviking

Why does the std::source_location::function_name() return a string equivalent to __builtin_FUNCTION() instead of __FUNCSIG__? Are there any plans to change that in the future?

The <source_location> header was introduced PR #664, and there was a discussion starting from this comment on improving the informativeness of the std::source_location::function_name(). There are also two (1, 2) DevCom tickets that are both in the “Under review” status since August 10, 2021, but there are no feedback since then.

The suggestion is to make the std::source_location::function_name() return the same string as __FUNCSIG__ does, analogous to what GCC and Clang do by returning the string equivalent to __PRETTY_FUNCTION__. Here is the side by side comparison (compiler explorer). Please note, that GCC and Clang also provide the __builtin_FUNCTION() intrinsic which works the same as MSVC implementation, however, libstdc++ and libc++ implementations of source_location rely on the __builtin_source_location() intrinsic which works differently.

This is not a bug report because the current implementation is definitely valid by the C++ Standard, but I find it a significant usability improvement for using source_location, thus bringing it here.

If I am misunderstanding some concepts, please correct me in the comments.

Also tracked by internal VSO-1614161 / AB#1614161 .

Metadata

Metadata

Assignees

No one assigned

    Labels

    compilerCompiler work involvedfixedSomething works now, yay!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions