C++ Logo

SG7

Advanced search

Subject: Re: [isocpp-ext] CWG1962+CWG2362 type of __func__ / __func__ should be constexpr
From: Peter Dimov (pdimov_at_[hidden])
Date: 2020-04-30 08:40:30


Gabriel Dos Reis wrote:

> I don’t see an “improvement” from the C++ side to __func__ as increasing C
> compatibility.
>
> It is a C facility and any improvement to it should be deferred to WG14.
> Hence, leave it alone.

Why would it be a problem to use

    static constexpr char _ _func_ _[] = "function-name";

in C++? This remains compatible with the C definition, doesn't it?

I'm not sure I see what additional problems this would create. At the
moment,

inline char f()
{
    return __func__[0];
}

already causes an ODR violation if __func__[0] doesn't have the same value
in two translation units. Allowing people to instantiate templates with
__func__[0] doesn't seem to add much.


SG7 list run by herb.sutter at gmail.com

Older Archives on Google Groups