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

            Bug ID: 79329
           Summary: bogus operator delete access check during
                    instantiation of new-expression
           Product: gcc
           Version: 7.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: richard-gccbugzilla at metafoo dot co.uk
  Target Milestone: ---

Testcase:

struct A {
  A();
  void *operator new(unsigned long, void*);
private:
  void operator delete(void*, int);
};
A *p = new (p) A;

gives a bogus diagnostic:

<source>:7:16: error: 'static void A::operator delete(void*, int)' is private
within this context
A *p = new (p) A;
               ^
<source>:5:8: note: declared private here
  void operator delete(void*, int);
       ^~~~~~~~

Adding a second irrelevant operator delete overload suppresses the diagnostic.
(Perhaps the access check is being performed prior to filtering out
non-matching operator delete functions in the case where the lookup result is
not an overload set.)

Reply via email to