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

            Bug ID: 95593
           Summary: [c++20] decltype() on consteval compiles invalid code
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bruck.michael at gmail dot com
  Target Milestone: ---

https://gcc.godbolt.org/z/24novC

This is from N4835 ([expr.const] after 14.7) and does not fail as required:

struct N {
  constexpr N() {}
  N(N const&) = delete;
};

template<typename T> constexpr void bad_assert_copyable() { T t; T t2 = t; }
using ineffective = decltype(bad_assert_copyable<N>());
// bad_assert_copyable<N> is not needed for constant evaluation
// (and thus not instantiated)

template<typename T> consteval void assert_copyable() { T t; T t2 = t; }
using check = decltype(assert_copyable<N>());
// error: assert_copyable<N> is instantiated (because it is needed for constant
// evaluation), but the attempt to copy t is ill-formed

Reply via email to