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

            Bug ID: 115251
           Summary: [DR 1581] Conversion operator that is needed for
                    constant evaluation not instantiated in
                    requires-expression
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mital at mitalashok dot co.uk
  Target Milestone: ---

Discovered at https://github.com/llvm/llvm-project/issues/93364

struct Universal {
    template <typename T>
    constexpr operator T() { 
        static_assert(false);
    }
};
static_assert(requires { int{Universal()}; });

template<typename T>
struct NotUniversal {
    constexpr operator T() {
        static_assert(false);
    }
};
static_assert(requires { int{NotUniversal<int>()}; });

These are both accepted even though it should instantiate the operator.

Changing the assert to use `sizeof` instead of `requires` causes this to not
compile as expected.

https://godbolt.org/z/En3PjaYzc

Reply via email to