C++ Logo

sg7

Advanced search

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

From: Herring, Davis <herring_at_[hidden]>
Date: Thu, 30 Apr 2020 14:15:08 +0000
> Maybe I missed it or maybe it is too obvious, but I didn't see any
> discussion about how these issues with __func__ do or don't apply to
> std::source_location::current().function_name(), which is usable in
> constexpr context. While __func__ being an array is its own unique
> problem, as far as I can see, the other issues discussed seem to apply
> just as much to the modern version.

There doesn't appear to be any guarantee that, given

  constexpr auto f=std::source_location::current().function_name();

*f is usable in a constant expression; consider

  char a;
  constexpr auto p=&a;

as a trivial counterexample. This "half constexpr" situation can't pertain for an array.

Davis

Received on 2020-04-30 09:18:12