C++ Logo

sg7

Advanced search

Re: [SG7] [isocpp-ext] CWG1962+CWG2362 type of __func__ / __func__ should be constexpr

From: Gabriel Dos Reis <gdr_at_[hidden]>
Date: Wed, 29 Apr 2020 00:12:24 +0000
  * Can you please provide a rationale for your position?

I don’t see deprecation as a viable option – this is a facility primarily introduced and “controlled” by C.
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.

-- Gaby

From: JF Bastien <cxx_at_[hidden]>
Sent: Tuesday, April 28, 2020 1:59 PM
To: Gabriel Dos Reis <gdr_at_[hidden]>
Cc: ext_at_[hidden]; sg7_at_[hidden]
Subject: Re: [isocpp-ext] CWG1962+CWG2362 type of __func__ / __func__ should be constexpr

On Tue, Apr 28, 2020 at 1:46 PM Gabriel Dos Reis <gdr_at_[hidden]<mailto:gdr_at_[hidden]>> wrote:
Leave it alone.

Can you please provide a rationale for your position?


-- Gaby
________________________________
From: Ext <ext-bounces_at_[hidden]g<mailto:ext-bounces_at_[hidden]>> on behalf of JF Bastien via Ext <ext_at_[hidden]<mailto:ext_at_[hidden]>>
Sent: Tuesday, April 28, 2020 11:10:02 AM
To: Evolution Working Group mailing list <ext_at_[hidden]<mailto:ext_at_[hidden]>>; sg7_at_[hidden]<mailto:sg7_at_[hidden]> <sg7_at_[hidden]<mailto:sg7_at_[hidden]>>
Cc: JF Bastien <cxx_at_[hidden]<mailto:cxx_at_[hidden]>>
Subject: [isocpp-ext] CWG1962+CWG2362 type of __func__ / __func__ should be constexpr

Hello EWG and Reflection,

We looked at CWG1962<https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwg21.link%2FCWG1962&data=02%7C01%7Cgdr%40microsoft.com%7Cc348a1b1f17547e6d00c08d7ebb7033e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637237043604094877&sdata=T%2BO%2FmAANjlOP1aZC8qzuPwxpr%2FyQh2daC8USdzpWep4%3D&reserved=0> and CWG2362<https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwg21.link%2FCWG2362&data=02%7C01%7Cgdr%40microsoft.com%7Cc348a1b1f17547e6d00c08d7ebb7033e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637237043604104875&sdata=mQB%2BcDj2h7bvfsyinE0BvAP12CScCyY1%2F0rwRRd80CI%3D&reserved=0> during our telecon (notes here<https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwiki.edg.com%2Fbin%2Fview%2FWg21summer2020%2FEWG-IssueProcessing-23-Apr-2020&data=02%7C01%7Cgdr%40microsoft.com%7Cc348a1b1f17547e6d00c08d7ebb7033e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637237043604104875&sdata=x%2FjdjbY1tqf1t6t7KlAo5TwuQ524As7D7t%2B0ZKJL2fE%3D&reserved=0>). We agree that there's a language issue.

Using the details below, I'd like y'all to consider: do we want to fix this issue, or leave it as-is because better mechanisms will eventually lead us to deprecate __func__?

Richard summarized both issues thusly: The deep question here is about __func__ and the ODR. Does EWG want implementations to somehow behave as if __func__ is the same in all copies of an inline function (in which case it can have an array type and be usable in constant expressions, but the demangling algorithm used to construct it becomes part of the ABI), or does EWG want implementations to behave as if __func__ may differ between copies, so is in effect not known until runtime (in which case it must have either pointer or incomplete array type, and its value is not usable in constant expressions — but its address could still be usable).

Consulting with Hana, it indeed seems like Reflection<https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwg21.link%2FP1240&data=02%7C01%7Cgdr%40microsoft.com%7Cc348a1b1f17547e6d00c08d7ebb7033e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637237043604114873&sdata=n1SF3sN4mOvK0MxetnKn%2B4YLf5bnN79k%2FVDc0Hqlp48%3D&reserved=0> can replace __func__:
namespace std::meta {
  consteval auto name_of(info entity)->std::string {...};
  consteval auto display_name_of(info entity)->std::string {...};
}
consteval auto current_function()->info {...}

Further, Hana points out that C++20 has the following:
std::source_location::function_name

Cherry on top: I don't think WG14 will adopt either of these soon. If we deprecate __func__ we're creating extra divergence between C and C++.

Given these facts: do we want to spend time fixing __func__, or do we want to leave it alone?

Thanks,

JF


Received on 2020-04-28 19:15:25