https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124414

            Bug ID: 124414
           Summary: [reflection] Invalid constexpr variable accepted with
                    void pointer to consteval-only type
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: friedkeenan at protonmail dot com
  Target Milestone: ---

The following code compiles, but should fail to do so:
```
struct type_erased_consteval {
    static constexpr auto reflection = ^^int;

    const void *consteval_only_ptr = &reflection;
};

constexpr auto result = type_erased_consteval{};
```
Godbolt link: https://godbolt.org/z/s94c4TYqo

The experimental Clang reflection branch successfully rejects this code.

I believe this specifically should fail on the basis of the clause "No
constituent value of pointer type points to or past an object whose complete
object is of consteval-only type" from
https://eel.is/c++draft/expr.const#21.2.5.2
  • [Bug c++/124414] New: [refl... friedkeenan at protonmail dot com via Gcc-bugs

Reply via email to