public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/91618] template-id required to friend a function template, even for a qualified-id
       [not found] <bug-91618-4@http.gcc.gnu.org/bugzilla/>
@ 2020-08-29 15:06 ` language.lawyer at gmail dot com
  2020-11-04 15:51 ` redi at gcc dot gnu.org
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: language.lawyer at gmail dot com @ 2020-08-29 15:06 UTC (permalink / raw)
  To: gcc-bugs

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

Language Lawyer <language.lawyer at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |language.lawyer at gmail dot com

--- Comment #5 from Language Lawyer <language.lawyer at gmail dot com> ---
Dup of bug 88725

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

* [Bug c++/91618] template-id required to friend a function template, even for a qualified-id
       [not found] <bug-91618-4@http.gcc.gnu.org/bugzilla/>
  2020-08-29 15:06 ` [Bug c++/91618] template-id required to friend a function template, even for a qualified-id language.lawyer at gmail dot com
@ 2020-11-04 15:51 ` redi at gcc dot gnu.org
  2020-11-04 15:51 ` redi at gcc dot gnu.org
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2020-11-04 15:51 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |haining.cpp at gmail dot com

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

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

* [Bug c++/91618] template-id required to friend a function template, even for a qualified-id
       [not found] <bug-91618-4@http.gcc.gnu.org/bugzilla/>
  2020-08-29 15:06 ` [Bug c++/91618] template-id required to friend a function template, even for a qualified-id language.lawyer at gmail dot com
  2020-11-04 15:51 ` redi at gcc dot gnu.org
@ 2020-11-04 15:51 ` redi at gcc dot gnu.org
  2021-12-13 16:06 ` pinskia at gcc dot gnu.org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2020-11-04 15:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
>From Bug 88725

gcc fails to deduce that the friend declaration refers to ::func<int> in the
below

```
template <typename T>
void func(T);

class Cls {
    friend void ::func(int);
};
```

Rejecting with 

```
error: 'void func(int)' should have been declared inside '::'
     friend void ::func(int);
                           ^
```

I believe this should be allowed by [temp.friend]/1.3:
http://eel.is/c++draft/temp.friend#1.3

see discussion here: https://stackoverflow.com/q/54055575/1013719

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

* [Bug c++/91618] template-id required to friend a function template, even for a qualified-id
       [not found] <bug-91618-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2020-11-04 15:51 ` redi at gcc dot gnu.org
@ 2021-12-13 16:06 ` pinskia at gcc dot gnu.org
  2021-12-13 16:07 ` pinskia at gcc dot gnu.org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-13 16:06 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Even though PR 100339 is newer, it has more details on the issue and even
references the revision which introduced the regressions so closing this issue
as a dup of bug 100339.

*** This bug has been marked as a duplicate of bug 100339 ***

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

* [Bug c++/91618] template-id required to friend a function template, even for a qualified-id
       [not found] <bug-91618-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2021-12-13 16:06 ` pinskia at gcc dot gnu.org
@ 2021-12-13 16:07 ` pinskia at gcc dot gnu.org
  2021-12-13 16:09 ` [Bug c++/91618] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-13 16:07 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |NEW
         Resolution|DUPLICATE                   |---

--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Actually lets do it the other way around.

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

* [Bug c++/91618] [9/10/11/12 Regression] template-id required to friend a function template, even for a qualified-id
       [not found] <bug-91618-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2021-12-13 16:07 ` pinskia at gcc dot gnu.org
@ 2021-12-13 16:09 ` pinskia at gcc dot gnu.org
  2022-01-17  9:00 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-13 16:09 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 100339 has been marked as a duplicate of this bug. ***

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

* [Bug c++/91618] [9/10/11/12 Regression] template-id required to friend a function template, even for a qualified-id
       [not found] <bug-91618-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2021-12-13 16:09 ` [Bug c++/91618] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
@ 2022-01-17  9:00 ` rguenth at gcc dot gnu.org
  2022-04-07 15:59 ` jason at gcc dot gnu.org
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-17  9:00 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |9.5
           Priority|P3                          |P2

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

* [Bug c++/91618] [9/10/11/12 Regression] template-id required to friend a function template, even for a qualified-id
       [not found] <bug-91618-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2022-01-17  9:00 ` rguenth at gcc dot gnu.org
@ 2022-04-07 15:59 ` jason at gcc dot gnu.org
  2022-04-07 20:11 ` jason at gcc dot gnu.org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2022-04-07 15:59 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #11 from Jason Merrill <jason at gcc dot gnu.org> ---
Interesting, seems that G++ never implemented that bullet.  Even though we
allowed the friend declaration, it didn't match the template:

template <class T> int f(T t) { return t.i; }

class A {
  friend int ::f(A);
  int i;
};

int main()
{
  f(A()); // link error, trying to call non-template function                   
}

I also notice that the bullet in question is gone in the C++23 draft, replaced
by new wording in [dcl.meaning.general]:

(2.2.1.3) — each remaining function template is replaced with the
specialization chosen by deduction from the friend declaration (13.10.3.7) or
discarded if deduction fails.

So, it's not clear to me that this really counts as a regression.

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

* [Bug c++/91618] [9/10/11/12 Regression] template-id required to friend a function template, even for a qualified-id
       [not found] <bug-91618-4@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2022-04-07 15:59 ` jason at gcc dot gnu.org
@ 2022-04-07 20:11 ` jason at gcc dot gnu.org
  2022-04-09  1:51 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2022-04-07 20:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

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

* [Bug c++/91618] [9/10/11/12 Regression] template-id required to friend a function template, even for a qualified-id
       [not found] <bug-91618-4@http.gcc.gnu.org/bugzilla/>
                   ` (8 preceding siblings ...)
  2022-04-07 20:11 ` jason at gcc dot gnu.org
@ 2022-04-09  1:51 ` cvs-commit at gcc dot gnu.org
  2022-04-29 21:25 ` [Bug c++/91618] [9/10/11 " cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-09  1:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 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:58586721c79f77224b8571a5dba732620d5546ab

commit r12-8065-g58586721c79f77224b8571a5dba732620d5546ab
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Apr 6 23:46:53 2022 -0400

    c++: friend implicit template instantiation [PR91618]

    This rule that for a friend with a qualified name we try to find a
    matching template was already in C++98, but it seems we never implemented
    it, and nobody reported it until 2019.

    This patch sets DECL_IMPLICIT_INSTANTIATION to signal to
    check_explicit_specialization that we want to find a template, like
    grokfndecl already did for explicit template args.  check_classfn also
needs
    to call it, as check_classfn is called after the call to
    check_explicit_specialization in grokfndecl, whereas the call to
    set_decl_namespace comes sooner.  This inconsistency is inelegant, but
safer
    at this point in the release cycle; I'll unify them in stage 1.

            PR c++/91618
            PR c++/96604

    gcc/cp/ChangeLog:

            * name-lookup.cc (set_decl_namespace): Set
            DECL_IMPLICIT_INSTANTIATION if no non-template match.
            * pt.cc (check_explicit_specialization): Check it.
            * decl2.cc (check_classfn): Call it.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/friend7.C: Remove xfail.
            * g++.dg/template/friend72.C: New test.
            * g++.dg/template/friend72a.C: New test.
            * g++.dg/template/friend73.C: New test.

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

* [Bug c++/91618] [9/10/11 Regression] template-id required to friend a function template, even for a qualified-id
       [not found] <bug-91618-4@http.gcc.gnu.org/bugzilla/>
                   ` (9 preceding siblings ...)
  2022-04-09  1:51 ` cvs-commit at gcc dot gnu.org
@ 2022-04-29 21:25 ` cvs-commit at gcc dot gnu.org
  2022-05-13 15:29 ` jason at gcc dot gnu.org
  2023-05-03 19:25 ` cvs-commit at gcc dot gnu.org
  12 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-29 21:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 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:e9d2adc17d0dbe46db67e1b618dea888d5c7aca3

commit r13-55-ge9d2adc17d0dbe46db67e1b618dea888d5c7aca3
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Apr 8 13:48:25 2022 -0400

    c++: reorganize friend template matching [PR91618]

    The the different calling of check_explicit_specialization for class and
    namespace scope friends bothered me, so this patch combines them.

            PR c++/91618
            PR c++/96604

    gcc/cp/ChangeLog:

            * friend.cc (do_friend): Call check_explicit_specialization here.
            * decl.cc (grokdeclarator): Not here.
            * decl2.cc (check_classfn): Or here.

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

* [Bug c++/91618] [9/10/11 Regression] template-id required to friend a function template, even for a qualified-id
       [not found] <bug-91618-4@http.gcc.gnu.org/bugzilla/>
                   ` (10 preceding siblings ...)
  2022-04-29 21:25 ` [Bug c++/91618] [9/10/11 " cvs-commit at gcc dot gnu.org
@ 2022-05-13 15:29 ` jason at gcc dot gnu.org
  2023-05-03 19:25 ` cvs-commit at gcc dot gnu.org
  12 siblings, 0 replies; 13+ messages in thread
From: jason at gcc dot gnu.org @ 2022-05-13 15:29 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED
   Target Milestone|9.5                         |12.0

--- Comment #14 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to Jason Merrill from comment #11)
> So, it's not clear to me that this really counts as a regression.

So, I'm not inclined to backport it.

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

* [Bug c++/91618] [9/10/11 Regression] template-id required to friend a function template, even for a qualified-id
       [not found] <bug-91618-4@http.gcc.gnu.org/bugzilla/>
                   ` (11 preceding siblings ...)
  2022-05-13 15:29 ` jason at gcc dot gnu.org
@ 2023-05-03 19:25 ` cvs-commit at gcc dot gnu.org
  12 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-03 19:25 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

commit r14-460-g7ce078ceca42f184f6f60c3ca921b6e07cf2c4bd
Author: Jason Merrill <jason@redhat.com>
Date:   Wed May 3 13:32:55 2023 -0400

    c++: over-eager friend matching [PR109649]

    A bug in the simplification I did around 91618; at this point X<int>::f has
    DECL_IMPLICIT_INSTANTIATION set, but we've already identified what template
    it corresponds to, so we don't want to call check_explicit_specialization.

    To distinguish this case we need to look at DECL_TI_TEMPLATE.  grokfndecl
    has for a long time set it to the OVERLOAD in this case, while the new
cases
    I added for 91618 were leaving DECL_TEMPLATE_INFO null; let's adjust them
to
    match.

            PR c++/91618
            PR c++/109649

    gcc/cp/ChangeLog:

            * friend.cc (do_friend): Don't call check_explicit_specialization
if
            DECL_TEMPLATE_INFO is already set.
            * decl2.cc (check_classfn): Set DECL_TEMPLATE_INFO.
            * name-lookup.cc (set_decl_namespace): Likewise.

    gcc/testsuite/ChangeLog:

            * g++.dg/template/friend77.C: New test.

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

end of thread, other threads:[~2023-05-03 19:25 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-91618-4@http.gcc.gnu.org/bugzilla/>
2020-08-29 15:06 ` [Bug c++/91618] template-id required to friend a function template, even for a qualified-id language.lawyer at gmail dot com
2020-11-04 15:51 ` redi at gcc dot gnu.org
2020-11-04 15:51 ` redi at gcc dot gnu.org
2021-12-13 16:06 ` pinskia at gcc dot gnu.org
2021-12-13 16:07 ` pinskia at gcc dot gnu.org
2021-12-13 16:09 ` [Bug c++/91618] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
2022-01-17  9:00 ` rguenth at gcc dot gnu.org
2022-04-07 15:59 ` jason at gcc dot gnu.org
2022-04-07 20:11 ` jason at gcc dot gnu.org
2022-04-09  1:51 ` cvs-commit at gcc dot gnu.org
2022-04-29 21:25 ` [Bug c++/91618] [9/10/11 " cvs-commit at gcc dot gnu.org
2022-05-13 15:29 ` jason at gcc dot gnu.org
2023-05-03 19:25 ` cvs-commit 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).