public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53403] Function template friend denied access to private types of granting template class.
  2012-05-18 17:48 [Bug c++/53403] New: Function template friend denied access to private types of granting template class ibugs at qult dot net
@ 2012-05-18 17:38 ` ibugs at qult dot net
  2012-05-18 19:44 ` daniel.kruegler at googlemail dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ibugs at qult dot net @ 2012-05-18 17:38 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53403

Ignacy Gawedzki <ibugs at qult dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |minor


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

* [Bug c++/53403] New: Function template friend denied access to private types of granting template class.
@ 2012-05-18 17:48 ibugs at qult dot net
  2012-05-18 17:38 ` [Bug c++/53403] " ibugs at qult dot net
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: ibugs at qult dot net @ 2012-05-18 17:48 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53403

             Bug #: 53403
           Summary: Function template friend denied access to private
                    types of granting template class.
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: ibugs@qult.net


The following code compiles with GCC 4.4 but not since 4.5, until at least
4.7.0.

  template <typename T>
  class Foo {
    typedef void    type;
    template <typename U> friend void f();
  public:
    Foo() {}
  };

  template class Foo<void>;

  template <typename T>
  void f()
  {
    typedef Foo<void>::type    type;
  }

  int main()
  {
    f<void>();
  }

If the function template is declared before the definition of the class
template, or if the Foo<void> class is instantiated after f's definition, the
code compiles.  The error appears only with private types, not other private
members.

Easy to work around, but still... :/


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

* [Bug c++/53403] Function template friend denied access to private types of granting template class.
  2012-05-18 17:48 [Bug c++/53403] New: Function template friend denied access to private types of granting template class ibugs at qult dot net
  2012-05-18 17:38 ` [Bug c++/53403] " ibugs at qult dot net
@ 2012-05-18 19:44 ` daniel.kruegler at googlemail dot com
  2012-05-19  0:02 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2012-05-18 19:44 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53403

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler at
                   |                            |googlemail dot com

--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2012-05-18 18:27:16 UTC ---
The problem also exists for gcc 4.8.0 20120513 (experimental) with or without
activating C++11 support. Further, if the reference to the type in template f
is a dependent form, like

typedef typename Foo<T>::type type;

the error does not occur. This looks like a compiler-defect to me.


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

* [Bug c++/53403] Function template friend denied access to private types of granting template class.
  2012-05-18 17:48 [Bug c++/53403] New: Function template friend denied access to private types of granting template class ibugs at qult dot net
  2012-05-18 17:38 ` [Bug c++/53403] " ibugs at qult dot net
  2012-05-18 19:44 ` daniel.kruegler at googlemail dot com
@ 2012-05-19  0:02 ` redi at gcc dot gnu.org
  2012-10-04 23:06 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2012-05-19  0:02 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53403

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-05-18
     Ever Confirmed|0                           |1

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-05-18 23:23:50 UTC ---
Confirmed, this possibly got broken when Jason implemented the C++11 friend
rules


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

* [Bug c++/53403] Function template friend denied access to private types of granting template class.
  2012-05-18 17:48 [Bug c++/53403] New: Function template friend denied access to private types of granting template class ibugs at qult dot net
                   ` (2 preceding siblings ...)
  2012-05-19  0:02 ` redi at gcc dot gnu.org
@ 2012-10-04 23:06 ` paolo.carlini at oracle dot com
  2012-10-04 23:20 ` paolo at gcc dot gnu.org
  2012-10-04 23:23 ` paolo.carlini at oracle dot com
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-04 23:06 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53403

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-10-04 23:06:18 UTC ---
Works in mainline. I'm adding the testcase and closing the PR.


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

* [Bug c++/53403] Function template friend denied access to private types of granting template class.
  2012-05-18 17:48 [Bug c++/53403] New: Function template friend denied access to private types of granting template class ibugs at qult dot net
                   ` (3 preceding siblings ...)
  2012-10-04 23:06 ` paolo.carlini at oracle dot com
@ 2012-10-04 23:20 ` paolo at gcc dot gnu.org
  2012-10-04 23:23 ` paolo.carlini at oracle dot com
  5 siblings, 0 replies; 7+ messages in thread
From: paolo at gcc dot gnu.org @ 2012-10-04 23:20 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53403

--- Comment #4 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2012-10-04 23:19:52 UTC ---
Author: paolo
Date: Thu Oct  4 23:19:46 2012
New Revision: 192108

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=192108
Log:
2012-10-04  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/53403
    * g++.dg/template/friend53.C

Added:
    trunk/gcc/testsuite/g++.dg/template/friend53.C
Modified:
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/53403] Function template friend denied access to private types of granting template class.
  2012-05-18 17:48 [Bug c++/53403] New: Function template friend denied access to private types of granting template class ibugs at qult dot net
                   ` (4 preceding siblings ...)
  2012-10-04 23:20 ` paolo at gcc dot gnu.org
@ 2012-10-04 23:23 ` paolo.carlini at oracle dot com
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-04 23:23 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53403

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.8.0

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-10-04 23:23:42 UTC ---
Done.


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

end of thread, other threads:[~2012-10-04 23:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-18 17:48 [Bug c++/53403] New: Function template friend denied access to private types of granting template class ibugs at qult dot net
2012-05-18 17:38 ` [Bug c++/53403] " ibugs at qult dot net
2012-05-18 19:44 ` daniel.kruegler at googlemail dot com
2012-05-19  0:02 ` redi at gcc dot gnu.org
2012-10-04 23:06 ` paolo.carlini at oracle dot com
2012-10-04 23:20 ` paolo at gcc dot gnu.org
2012-10-04 23:23 ` paolo.carlini at oracle dot com

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