c++: operator new lookup [PR98249]
authorJason Merrill <jason@redhat.com>
Mon, 11 Apr 2022 17:06:05 +0000 (13:06 -0400)
committerJason Merrill <jason@redhat.com>
Mon, 11 Apr 2022 21:30:45 +0000 (17:30 -0400)
commitd087b59527a658a4de13febbb593edbf03339e93
treed504a13bebeb975d6b605d41a9978c88f5a15295
parentb1124648ff8f655307f264d7b353fd68e3b03e9c
c++: operator new lookup [PR98249]

The standard says, as we quote in the comment just above, that if we don't
find operator new in the allocated type, it should be looked up in the
global scope.  This is specifically ::, not just any namespace, and we
already give an error for an operator new declared in any other namespace.

PR c++/98249

gcc/cp/ChangeLog:

* call.cc (build_operator_new_call): Just look in ::.

gcc/testsuite/ChangeLog:

* g++.dg/lookup/new3.C: New test.
gcc/cp/call.cc
gcc/testsuite/g++.dg/lookup/new3.C [new file with mode: 0644]