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

* [Bug c++/98249] Improper ADL on the `arg` in `new (arg) T`
  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 ` 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
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-19  6:15 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.5.3
           Keywords|                            |rejects-valid
      Known to work|                            |4.4.7

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Hmm, something changed between GCC 4.5 and 4.4 which caused this to be rejected
...

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

* [Bug c++/98249] [9/10/11/12 Regression] Improper ADL on the `arg` in `new (arg) T`
  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 ` pinskia at gcc dot gnu.org
  2022-04-11 17:06 ` jason at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-19  6:21 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |9.5
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=34158
            Summary|Improper ADL on the `arg`   |[9/10/11/12 Regression]
                   |in `new (arg) T`            |Improper ADL on the `arg`
                   |                            |in `new (arg) T`

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I suspect the cause was the patch for PR 34158 (but I could be wrong).

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

* [Bug c++/98249] [9/10/11/12 Regression] Improper ADL on the `arg` in `new (arg) T`
  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
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2022-04-11 17:06 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2022-04-11
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org
                 CC|                            |jason at gcc dot gnu.org
     Ever confirmed|0                           |1

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

* [Bug c++/98249] [9/10/11/12 Regression] Improper ADL on the `arg` in `new (arg) T`
  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
                   ` (2 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-11 21:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:d087b59527a658a4de13febbb593edbf03339e93

commit r12-8093-gd087b59527a658a4de13febbb593edbf03339e93
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.cc (build_operator_new_call): Just look in ::.

    gcc/testsuite/ChangeLog:

            * g++.dg/lookup/new3.C: New test.

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

* [Bug c++/98249] [9/10/11 Regression] Improper ADL on the `arg` in `new (arg) T`
  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
                   ` (3 preceding siblings ...)
  2022-04-11 21:31 ` cvs-commit at gcc dot gnu.org
@ 2022-04-12 20:14 ` cvs-commit at gcc dot gnu.org
  2022-05-12 21:14 ` [Bug c++/98249] [9/10 " cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-12 20:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

https://gcc.gnu.org/g:7aa5f05583066f5b3146c999319288631c75597f

commit r11-9830-g7aa5f05583066f5b3146c999319288631c75597f
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.

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

* [Bug c++/98249] [9/10 Regression] Improper ADL on the `arg` in `new (arg) T`
  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
                   ` (4 preceding siblings ...)
  2022-04-12 20:14 ` [Bug c++/98249] [9/10/11 " cvs-commit at gcc dot gnu.org
@ 2022-05-12 21:14 ` 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
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-12 21:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

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.

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

* [Bug c++/98249] [9 Regression] Improper ADL on the `arg` in `new (arg) T`
  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
                   ` (5 preceding siblings ...)
  2022-05-12 21:14 ` [Bug c++/98249] [9/10 " cvs-commit at gcc dot gnu.org
@ 2022-05-13 17:41 ` cvs-commit at gcc dot gnu.org
  2022-05-13 17:50 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-13 17:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

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.

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

* [Bug c++/98249] [9 Regression] Improper ADL on the `arg` in `new (arg) T`
  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
                   ` (6 preceding siblings ...)
  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
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2022-05-13 17:50 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #7 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 9.5/10.4/11.4/12.

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