https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125519
Bug ID: 125519
Summary: [reflection] `access_context::current().scope()`
ignores local classes
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ensadc at mailnesia dot com
Target Milestone: ---
https://gcc.godbolt.org/z/M1rTo5cbv
====
#include <meta>
template<auto V> struct A { static constexpr auto value = V; };
consteval std::meta::info test() {
struct Local {
using T = A<std::meta::access_context::current().scope()>;
using U = A<std::meta::current_class()>; // Error
};
return Local::T::value;
}
static_assert(std::meta::identifier_of(test()) == "Local"); // Error
====
<source>: In function 'consteval std::meta::info test()':
<source>:8:47: error: uncaught exception of type 'std::meta::exception';
'what()': 'current scope does not represent a class nor a member function'
8 | using U = A<std::meta::current_class()>; // Error
| ^
<source>: At global scope:
<source>:13:48: error: static assertion failed
13 | static_assert(std::meta::identifier_of(test()) == "Local"); // Error
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
====
I expect that there's no error. That is, GCC should not produce an error on the
lines that are marked "Error".