public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97010] New: C++20 ADL and function templates that are not visible (P0846R0) fails on call with templated type
@ 2020-09-10 13:45 kirshamir at gmail dot com
  2020-09-10 14:14 ` [Bug c++/97010] " mpolacek at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: kirshamir at gmail dot com @ 2020-09-10 13:45 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97010
           Summary: C++20 ADL and function templates that are not visible
                    (P0846R0) fails on call with templated type
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kirshamir at gmail dot com
  Target Milestone: ---

#include <iostream>
#include <tuple>

template<class Tuple>
void print(const Tuple& tup) {
    // P0846R0: ADL should work here correctly
    std::cout << get<0>(tup) << std::endl; // fails with gcc
}

int main() {
    auto two_ints = std::make_tuple(1, 2);
    std::cout << get<0>(two_ints) << std::endl;  // ok
    print(two_ints);
}

Code: https://godbolt.org/z/YGGaEo

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

* [Bug c++/97010] C++20 ADL and function templates that are not visible (P0846R0) fails on call with templated type
  2020-09-10 13:45 [Bug c++/97010] New: C++20 ADL and function templates that are not visible (P0846R0) fails on call with templated type kirshamir at gmail dot com
@ 2020-09-10 14:14 ` mpolacek at gcc dot gnu.org
  2020-09-10 22:16 ` mpolacek at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-09-10 14:14 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |mpolacek at gcc dot gnu.org
                 CC|                            |mpolacek at gcc dot gnu.org
           Keywords|                            |rejects-valid
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2020-09-10
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Mine.

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

* [Bug c++/97010] C++20 ADL and function templates that are not visible (P0846R0) fails on call with templated type
  2020-09-10 13:45 [Bug c++/97010] New: C++20 ADL and function templates that are not visible (P0846R0) fails on call with templated type kirshamir at gmail dot com
  2020-09-10 14:14 ` [Bug c++/97010] " mpolacek at gcc dot gnu.org
@ 2020-09-10 22:16 ` mpolacek at gcc dot gnu.org
  2020-10-07 21:25 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-09-10 22:16 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
https://gcc.gnu.org/pipermail/gcc-patches/2020-September/553664.html

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

* [Bug c++/97010] C++20 ADL and function templates that are not visible (P0846R0) fails on call with templated type
  2020-09-10 13:45 [Bug c++/97010] New: C++20 ADL and function templates that are not visible (P0846R0) fails on call with templated type kirshamir at gmail dot com
  2020-09-10 14:14 ` [Bug c++/97010] " mpolacek at gcc dot gnu.org
  2020-09-10 22:16 ` mpolacek at gcc dot gnu.org
@ 2020-10-07 21:25 ` cvs-commit at gcc dot gnu.org
  2020-10-20 13:38 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-10-07 21:25 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:635072248a426c933c74ef4431e82401249b6218

commit r11-3709-g635072248a426c933c74ef4431e82401249b6218
Author: Marek Polacek <polacek@redhat.com>
Date:   Thu Sep 10 17:27:43 2020 -0400

    c++: Fix P0846 (ADL and function templates) in template [PR97010]

    To quickly recap, P0846 says that a name is also considered to refer to
    a template if it is an unqualified-id followed by a < and name lookup
    finds either one or more functions or finds nothing.

    In a template, when parsing a function call that has type-dependent
    arguments, we can't perform ADL right away so we set KOENIG_LOOKUP_P in
    the call to remember to do it when instantiating the call
    (tsubst_copy_and_build/CALL_EXPR).  When the called function is a
    function template, we represent the call with a TEMPLATE_ID_EXPR;
    usually the operand is an OVERLOAD.

    In the P0846 case though, the operand can be an IDENTIFIER_NODE, when
    name lookup found nothing when parsing the template name.  But we
    weren't handling this correctly in tsubst_copy_and_build.  First
    we need to pass the FUNCTION_P argument from <case TEMPLATE_ID_EXPR> to
    <case IDENTIFIER_NODE>, otherwise we give a bogus error.  And then in
    <case CALL_EXPR> we need to perform ADL.  The rest of the changes is to
    give better errors when ADL didn't find anything.

    gcc/cp/ChangeLog:

            PR c++/97010
            * pt.c (tsubst_copy_and_build) <case TEMPLATE_ID_EXPR>: Call
            tsubst_copy_and_build explicitly instead of using the RECUR macro.
            Handle a TEMPLATE_ID_EXPR with an IDENTIFIER_NODE as its operand.
            <case CALL_EXPR>: Perform ADL for a TEMPLATE_ID_EXPR with an
            IDENTIFIER_NODE as its operand.

    gcc/testsuite/ChangeLog:

            PR c++/97010
            * g++.dg/cpp2a/fn-template21.C: New test.
            * g++.dg/cpp2a/fn-template22.C: New test.

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

* [Bug c++/97010] C++20 ADL and function templates that are not visible (P0846R0) fails on call with templated type
  2020-09-10 13:45 [Bug c++/97010] New: C++20 ADL and function templates that are not visible (P0846R0) fails on call with templated type kirshamir at gmail dot com
                   ` (2 preceding siblings ...)
  2020-10-07 21:25 ` cvs-commit at gcc dot gnu.org
@ 2020-10-20 13:38 ` cvs-commit at gcc dot gnu.org
  2020-10-20 13:39 ` mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-10-20 13:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Marek Polacek
<mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:257bbf154cd2b83eb02c99db73537e3b8ba3a6e7

commit r10-8915-g257bbf154cd2b83eb02c99db73537e3b8ba3a6e7
Author: Marek Polacek <polacek@redhat.com>
Date:   Thu Sep 10 17:27:43 2020 -0400

    c++: Fix P0846 (ADL and function templates) in template [PR97010]

    To quickly recap, P0846 says that a name is also considered to refer to
    a template if it is an unqualified-id followed by a < and name lookup
    finds either one or more functions or finds nothing.

    In a template, when parsing a function call that has type-dependent
    arguments, we can't perform ADL right away so we set KOENIG_LOOKUP_P in
    the call to remember to do it when instantiating the call
    (tsubst_copy_and_build/CALL_EXPR).  When the called function is a
    function template, we represent the call with a TEMPLATE_ID_EXPR;
    usually the operand is an OVERLOAD.

    In the P0846 case though, the operand can be an IDENTIFIER_NODE, when
    name lookup found nothing when parsing the template name.  But we
    weren't handling this correctly in tsubst_copy_and_build.  First
    we need to pass the FUNCTION_P argument from <case TEMPLATE_ID_EXPR> to
    <case IDENTIFIER_NODE>, otherwise we give a bogus error.  And then in
    <case CALL_EXPR> we need to perform ADL.  The rest of the changes is to
    give better errors when ADL didn't find anything.

    gcc/cp/ChangeLog:

            PR c++/97010
            * pt.c (tsubst_copy_and_build) <case TEMPLATE_ID_EXPR>: Call
            tsubst_copy_and_build explicitly instead of using the RECUR macro.
            Handle a TEMPLATE_ID_EXPR with an IDENTIFIER_NODE as its operand.
            <case CALL_EXPR>: Perform ADL for a TEMPLATE_ID_EXPR with an
            IDENTIFIER_NODE as its operand.

    gcc/testsuite/ChangeLog:

            PR c++/97010
            * g++.dg/cpp2a/fn-template21.C: New test.
            * g++.dg/cpp2a/fn-template22.C: New test.

    (cherry picked from commit 635072248a426c933c74ef4431e82401249b6218)

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

* [Bug c++/97010] C++20 ADL and function templates that are not visible (P0846R0) fails on call with templated type
  2020-09-10 13:45 [Bug c++/97010] New: C++20 ADL and function templates that are not visible (P0846R0) fails on call with templated type kirshamir at gmail dot com
                   ` (3 preceding siblings ...)
  2020-10-20 13:38 ` cvs-commit at gcc dot gnu.org
@ 2020-10-20 13:39 ` mpolacek at gcc dot gnu.org
  2021-08-04 11:47 ` redi at gcc dot gnu.org
  2021-08-04 11:48 ` redi at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-10-20 13:39 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

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

--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.

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

* [Bug c++/97010] C++20 ADL and function templates that are not visible (P0846R0) fails on call with templated type
  2020-09-10 13:45 [Bug c++/97010] New: C++20 ADL and function templates that are not visible (P0846R0) fails on call with templated type kirshamir at gmail dot com
                   ` (4 preceding siblings ...)
  2020-10-20 13:39 ` mpolacek at gcc dot gnu.org
@ 2021-08-04 11:47 ` redi at gcc dot gnu.org
  2021-08-04 11:48 ` redi at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-04 11:47 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |johelegp at gmail dot com

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
*** Bug 96193 has been marked as a duplicate of this bug. ***

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

* [Bug c++/97010] C++20 ADL and function templates that are not visible (P0846R0) fails on call with templated type
  2020-09-10 13:45 [Bug c++/97010] New: C++20 ADL and function templates that are not visible (P0846R0) fails on call with templated type kirshamir at gmail dot com
                   ` (5 preceding siblings ...)
  2021-08-04 11:47 ` redi at gcc dot gnu.org
@ 2021-08-04 11:48 ` redi at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-04 11:48 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |10.3

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

end of thread, other threads:[~2021-08-04 11:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-10 13:45 [Bug c++/97010] New: C++20 ADL and function templates that are not visible (P0846R0) fails on call with templated type kirshamir at gmail dot com
2020-09-10 14:14 ` [Bug c++/97010] " mpolacek at gcc dot gnu.org
2020-09-10 22:16 ` mpolacek at gcc dot gnu.org
2020-10-07 21:25 ` cvs-commit at gcc dot gnu.org
2020-10-20 13:38 ` cvs-commit at gcc dot gnu.org
2020-10-20 13:39 ` mpolacek at gcc dot gnu.org
2021-08-04 11:47 ` redi at gcc dot gnu.org
2021-08-04 11:48 ` redi 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).