public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109649] New: GCC accepts invalid inaccessible friend declaration of member function
@ 2023-04-27 15:51 jlame646 at gmail dot com
  2023-04-27 15:58 ` [Bug c++/109649] [13/14 Regression] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: jlame646 at gmail dot com @ 2023-04-27 15:51 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109649
           Summary: GCC accepts invalid inaccessible friend declaration of
                    member function
           Product: gcc
           Version: 13.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jlame646 at gmail dot com
  Target Milestone: ---

The following invalid programs explained here:
https://stackoverflow.com/a/76120963/12002570 can be compiled with gcc but
rejected by msvc and clang. See demo: https://godbolt.org/z/Mz8cq3G5n

```
template <typename>
class X {

    void f(){}
};
class Y
{
    friend void X<int>::f();  
};

int main()
{
    X<int> t;
    t.f();
    Y b;
}
```

As we can note the above program compiles with gcc trunk.

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

* [Bug c++/109649] [13/14 Regression] GCC accepts invalid inaccessible friend declaration of member function
  2023-04-27 15:51 [Bug c++/109649] New: GCC accepts invalid inaccessible friend declaration of member function jlame646 at gmail dot com
@ 2023-04-27 15:58 ` pinskia at gcc dot gnu.org
  2023-04-27 16:07 ` mpolacek at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-27 15:58 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |13.1.0
             Status|UNCONFIRMED                 |NEW
      Known to work|                            |12.2.0
     Ever confirmed|0                           |1
           Keywords|                            |needs-bisection
            Summary|GCC accepts invalid         |[13/14 Regression] GCC
                   |inaccessible friend         |accepts invalid
                   |declaration of member       |inaccessible friend
                   |function                    |declaration of member
                   |                            |function
   Target Milestone|---                         |13.2
   Last reconfirmed|                            |2023-04-27

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

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

* [Bug c++/109649] [13/14 Regression] GCC accepts invalid inaccessible friend declaration of member function
  2023-04-27 15:51 [Bug c++/109649] New: GCC accepts invalid inaccessible friend declaration of member function jlame646 at gmail dot com
  2023-04-27 15:58 ` [Bug c++/109649] [13/14 Regression] " pinskia at gcc dot gnu.org
@ 2023-04-27 16:07 ` mpolacek at gcc dot gnu.org
  2023-05-03 17:12 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-04-27 16:07 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|needs-bisection             |
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |mpolacek at gcc dot gnu.org

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Changed in r13-55-ge9d2adc17d0dbe:

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

    c++: reorganize friend template matching [PR91618]

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

* [Bug c++/109649] [13/14 Regression] GCC accepts invalid inaccessible friend declaration of member function
  2023-04-27 15:51 [Bug c++/109649] New: GCC accepts invalid inaccessible friend declaration of member function jlame646 at gmail dot com
  2023-04-27 15:58 ` [Bug c++/109649] [13/14 Regression] " pinskia at gcc dot gnu.org
  2023-04-27 16:07 ` mpolacek at gcc dot gnu.org
@ 2023-05-03 17:12 ` jason at gcc dot gnu.org
  2023-05-03 19:24 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2023-05-03 17:12 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

* [Bug c++/109649] [13/14 Regression] GCC accepts invalid inaccessible friend declaration of member function
  2023-04-27 15:51 [Bug c++/109649] New: GCC accepts invalid inaccessible friend declaration of member function jlame646 at gmail dot com
                   ` (2 preceding siblings ...)
  2023-05-03 17:12 ` jason at gcc dot gnu.org
@ 2023-05-03 19:24 ` cvs-commit at gcc dot gnu.org
  2023-05-03 19:25 ` cvs-commit at gcc dot gnu.org
  2023-05-03 19:25 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-03 19:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:6138e862038180c7cfb94d6c120bd0b76da382ae

commit r13-7283-g6138e862038180c7cfb94d6c120bd0b76da382ae
Author: Jason Merrill <jason@redhat.com>
Date:   Wed May 3 14:16:00 2023 -0400

    Revert "c++: reorganize friend template matching [PR91618]"

    This patch was just a cleanup after the actual bugfix, so let's revert it
on
    the branch.

            PR c++/109649

    This reverts commit e9d2adc17d0dbe46db67e1b618dea888d5c7aca3.

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

* [Bug c++/109649] [13/14 Regression] GCC accepts invalid inaccessible friend declaration of member function
  2023-04-27 15:51 [Bug c++/109649] New: GCC accepts invalid inaccessible friend declaration of member function jlame646 at gmail dot com
                   ` (3 preceding siblings ...)
  2023-05-03 19:24 ` cvs-commit at gcc dot gnu.org
@ 2023-05-03 19:25 ` cvs-commit at gcc dot gnu.org
  2023-05-03 19:25 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ 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=109649

--- Comment #4 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] 7+ messages in thread

* [Bug c++/109649] [13/14 Regression] GCC accepts invalid inaccessible friend declaration of member function
  2023-04-27 15:51 [Bug c++/109649] New: GCC accepts invalid inaccessible friend declaration of member function jlame646 at gmail dot com
                   ` (4 preceding siblings ...)
  2023-05-03 19:25 ` cvs-commit at gcc dot gnu.org
@ 2023-05-03 19:25 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jason 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=109649

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

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

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 13.2/14.

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

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

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-27 15:51 [Bug c++/109649] New: GCC accepts invalid inaccessible friend declaration of member function jlame646 at gmail dot com
2023-04-27 15:58 ` [Bug c++/109649] [13/14 Regression] " pinskia at gcc dot gnu.org
2023-04-27 16:07 ` mpolacek at gcc dot gnu.org
2023-05-03 17:12 ` jason at gcc dot gnu.org
2023-05-03 19:24 ` cvs-commit at gcc dot gnu.org
2023-05-03 19:25 ` cvs-commit at gcc dot gnu.org
2023-05-03 19:25 ` 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).