This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/79706] New: invalid delete[] expression doesn't cause substitution failure


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

            Bug ID: 79706
           Summary: invalid delete[] expression doesn't cause substitution
                    failure
           Product: gcc
           Version: 6.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

template<bool, typename = void> struct enable_if { };
template<typename T> struct enable_if<true, T> { using type = T; };

// Check that delete expression is well-formed:
template<bool _Array, typename _Yp>
  auto
  ck_delete(_Yp* __p)
  -> typename enable_if<!_Array, decltype(delete __p)>::type;

// Check that delete[] expression is well-formed:
template<bool _Array, typename _Yp>
  auto
  ck_delete(_Yp* __p)
  -> typename enable_if<_Array, decltype(delete[] __p)>::type
  { delete[] __p; }

struct A {
  void operator delete(void*) = delete;
  void operator delete[](void*) = delete;
};


auto f1 = &ck_delete<true, A>;  // error expected here

int main()
{
    f1(new A[1]);
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]