[Bug c++/126795] New: deleting a void* should be an error in SFINAE context

rs2740 at gmail dot com via Gcc-bugs <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126795

            Bug ID: 126795
           Summary: deleting a void* should be an error in SFINAE context
           Product: gcc
           Version: 16.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rs2740 at gmail dot com
  Target Milestone: ---

template<class T>
concept deletable = requires(T* p) { delete p; };

static_assert(!deletable<void>); // fires

Since at least C++11 deleting a void* is ill-formed:

The operand shall have a pointer to object type, or a class type having a
single non-explicit conversion function ([class.conv.fct]) to a pointer to
object type.

https://timsong-cpp.github.io/cppwp/std11/expr.delete#1

PR 115747 correctly treated deleting an incomplete type as an error in SFINAE
for C++26+.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.