public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98249] New: Improper ADL on the `arg` in `new (arg) T`
@ 2020-12-11 21:56 arthur.j.odwyer at gmail dot com
  2021-09-19  6:15 ` [Bug c++/98249] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: arthur.j.odwyer at gmail dot com @ 2020-12-11 21:56 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98249
           Summary: Improper ADL on the `arg` in `new (arg) T`
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arthur.j.odwyer at gmail dot com
  Target Milestone: ---

// https://godbolt.org/z/xavfej

#include <new>
struct Incomplete;
template<class T> struct Holder { T t; };
Holder<Incomplete> *p;
void test() {
    ::new (p) int;
    new (p) int;
}

In an "ADL call," the compiler needs to compute the associated types of
`Holder<Incomplete>`, which means it needs to complete that type in order to
check for friend declarations.  In a "non-ADL call" (such as a qualified call),
the compiler does NOT need to complete `Holder<Incomplete>`.  Since completing
`Holder<Incomplete>` produces a hard error, we can detect the difference
between an ADL and a non-ADL call.

All other compilers use "non-ADL calls" for both `::new (p) int` and `new (p)
int`: they don't attempt to complete the incomplete type. GCC uses "ADL calls"
for both, which means it hard-errors on both lines.

I'm not sure what the Standard has to say about this, but GCC disagrees with
all of Clang/MSVC/ICC, so I think GCC ought to change.

(Detected while testing libc++ patch https://reviews.llvm.org/D92884)

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-05-13 17:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-11 21:56 [Bug c++/98249] New: Improper ADL on the `arg` in `new (arg) T` arthur.j.odwyer at gmail dot com
2021-09-19  6:15 ` [Bug c++/98249] " pinskia at gcc dot gnu.org
2021-09-19  6:21 ` [Bug c++/98249] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
2022-04-11 17:06 ` jason at gcc dot gnu.org
2022-04-11 21:31 ` cvs-commit at gcc dot gnu.org
2022-04-12 20:14 ` [Bug c++/98249] [9/10/11 " cvs-commit at gcc dot gnu.org
2022-05-12 21:14 ` [Bug c++/98249] [9/10 " cvs-commit at gcc dot gnu.org
2022-05-13 17:41 ` [Bug c++/98249] [9 " cvs-commit at gcc dot gnu.org
2022-05-13 17:50 ` jason at gcc dot gnu.org

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).