public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r10-10719] c++: operator new lookup [PR98249] Date: Thu, 12 May 2022 21:14:42 +0000 (GMT) [thread overview] Message-ID: <20220512211442.3C75E3850425@sourceware.org> (raw) https://gcc.gnu.org/g:6c69f7c449cc1c0d48e13b8680023a59f541260e commit r10-10719-g6c69f7c449cc1c0d48e13b8680023a59f541260e 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 29e4a52b6c4..49eb673ebcc 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -4682,7 +4682,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; +}
reply other threads:[~2022-05-12 21:14 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220512211442.3C75E3850425@sourceware.org \ --to=jason@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).