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)