https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120366
Bug ID: 120366
Summary: __PRETTY_FUNCTION__ is sometimes an array of unknown
bound
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: barry.revzin at gmail dot com
Target Milestone: ---
Here's a reduced example of an issue we ran into:
using size_t = decltype(sizeof(0));
template <size_t N>
void accepts_bounded(char const(&)[N]) { }
void f() {
accepts_bounded(__PRETTY_FUNCTION__); // ok
[](auto){
accepts_bounded(__PRETTY_FUNCTION__); // ok
}(0);
}
template <class T>
void g(T) {
accepts_bounded(__PRETTY_FUNCTION__); // ok
[](auto){
accepts_bounded(__PRETTY_FUNCTION__); // error
}(0);
}
int main() {
accepts_bounded(__PRETTY_FUNCTION__); // ok
[]{
accepts_bounded(__PRETTY_FUNCTION__); // ok
}();
[](auto){
accepts_bounded(__PRETTY_FUNCTION__); // ok
}(0);
[](auto){
[](auto){
accepts_bounded(__PRETTY_FUNCTION__); // error
}(1);
}(0);
f();
g(2);
}
We expect __PRETTY_FUNCTION__ to be some char const[N]. And that seems to be
true... almost all the time. Except for a generic lambda that is inside of a
template, where __PRETTY_FUNCTION__ has type char const[] instead and so that
deduction fails.