From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A90013858435; Fri, 23 Feb 2024 13:57:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A90013858435 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1708696679; bh=nZW7Ikn3w4B83sCtjpDXqWJjS9IIGnSM3MkPEkVRwTk=; h=From:To:Subject:Date:From; b=Gu6rdDsY4ReXlqWlU9dDAai8MMWtVhhTqbtD7FAgiAhNhcnPdW1kcLgN93HZuTc0s 8D6guBxZKW+JXdM0lTkcoSoWjI5m1cYdXIqvofIzBdsN/Jy8S34nvWqrqo2Y7LcD7d ZzSoOB0HeJVmKf8cjr26thGnSd+fmMIb+Kq9qP5Q= From: "de34 at live dot cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/114078] New: operator new and operator delete are incorrectly acceptable as explicit object member functions Date: Fri, 23 Feb 2024 13:57:58 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: accepts-invalid X-Bugzilla-Severity: normal X-Bugzilla-Who: de34 at live dot cn X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114078 Bug ID: 114078 Summary: operator new and operator delete are incorrectly acceptable as explicit object member functions Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: accepts-invalid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: de34 at live dot cn Target Milestone: --- GCC currently accepts this wrong program while it shouldn't (https://godbolt.org/z/7jGnGqYPM), because member operator new/operator del= ete are always static member functions. #include #include struct S { void* operator new(this std::size_t); void operator delete(this S*, std::destroying_delete_t); operator S*() const; operator std::size_t() const; }; int main() { S{}.operator new(); S{}.operator delete(std::destroying_delete); } Similar to https://github.com/llvm/llvm-project/issues/82249 which is fixed recently.=