public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r9-10172] c++: operator new lookup [PR98249]
@ 2022-05-13 17:41 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2022-05-13 17:41 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:86d50501e487597d8b97f40d1c87dfcd694a9441

commit r9-10172-g86d50501e487597d8b97f40d1c87dfcd694a9441
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Apr 11 13:06:05 2022 -0400

    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.c (build_operator_new_call): Just look in ::.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/lookup/new3.C: New test.

Diff:
---
 gcc/cp/call.c                      |  1 -
 gcc/testsuite/g++.dg/lookup/new3.C | 10 ++++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 65fbff3b893..53ca229b909 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -4584,7 +4584,6 @@ build_operator_new_call (tree fnname, vec<tree, va_gc> **args,
 
      we disregard block-scope declarations of "operator new".  */
   fns = lookup_name_real (fnname, 0, 1, /*block_p=*/false, 0, 0);
-  fns = lookup_arg_dependent (fnname, fns, *args);
 
   if (align_arg)
     {
diff --git a/gcc/testsuite/g++.dg/lookup/new3.C b/gcc/testsuite/g++.dg/lookup/new3.C
new file mode 100644
index 00000000000..36afb5b48e2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lookup/new3.C
@@ -0,0 +1,10 @@
+// PR c++/98249
+
+#include <new>
+struct Incomplete;
+template<class T> struct Holder { T t; };
+Holder<Incomplete> *p;
+void test() {
+    ::new (p) int;
+    new (p) int;
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-13 17:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-13 17:41 [gcc r9-10172] c++: operator new lookup [PR98249] Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).