https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128835
Bug ID: 128835
Summary: [reflection] object_of doesn't throw when it should
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mpolacek at gcc dot gnu.org
Target Milestone: ---
```
// { dg-do compile { target c++26 } }
// { dg-additional-options "-freflection" }
#include <meta>
consteval bool
throws_p (std::meta::info r)
{
try { std::meta::object_of (r); }
catch (std::meta::exception &) { return true; }
return false;
}
int &get ();
int &rt = get ();
static_assert (throws_p (^^rt));
```
This should pass because:
Throws: meta::exception unless r is a reflection representing either
-- an object with static storage duration, or
-- a variable that either declares or refers to such an object, and if that
variable is a reference R, then either
-- R is usable in constant expressions, or [...]