C++ Logo

SG7

Advanced search

Subject: Re: [isocpp-ext] CWG1962+CWG2362 type of __func__ / __func__ should be constexpr
From: Herring, Davis (herring_at_[hidden])
Date: 2020-04-30 09:15:08


> 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


SG7 list run by herb.sutter at gmail.com

Older Archives on Google Groups