public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/50586] New: Template argument of type "pointer to function" of a template class causes usage error if template is instantiated with pointer-to-private-static-member-function
@ 2011-10-01  9:35 mouchtaris at gmail dot com
  2011-10-01 15:18 ` [Bug c++/50586] " daniel.kruegler at googlemail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: mouchtaris at gmail dot com @ 2011-10-01  9:35 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 50586
           Summary: Template argument of type "pointer to function" of a
                    template class causes usage error if template is
                    instantiated with
                    pointer-to-private-static-member-function
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: mouchtaris@gmail.com


Created attachment 25390
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25390
A small test file exhibiting the error.

If there is a declared template class, which accepts a pointer-to-function as a
non-type template parameter:

//////////////////////////
template <int (*f)(void)>
struct caller
  { int operator () (void) const { return (*f)(); } };
//////////////////////////

and is instantiated in a class with a pointer to a private static member
function:

//////////////////////////
class A {
  static int f (void) { return 0; }
public:
  caller<&f> get;
};
//////////////////////////

then G++ reports that "f" is private when used in the context of
caller::operator().

I haven't found anything in the standard that would impose this restriction.

(As a cue, this was reported as an error as well in older version of the vc
compiler, but in version 16.00 it is not an error any more)

I am attaching a small test file. I am not attaching any preprocessed file, as
there is no need. No preprocessor directives are used in this test.

I hope this has not been dealt before.

----------------- Detailed information -------------------

*** Compiler version: ***
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/spare/root/libexec/gcc/i686-pc-linux-gnu/4.6.1/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.6.1/configure --prefix=/spare/root
Thread model: posix
gcc version 4.6.1 (GCC)


*** Compilation command: ***
g++ -ansi -pedantic -Wall -Wextra t.cpp


*** Compiler output: ***
t.cpp: In member function 'int caller<f>::operator()() const [with int (* f)()
= A::f]':
t.cpp:26:   instantiated from here
t.cpp:13: error: 'static int A::f()' is private
t.cpp:5: error: within this context


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

* [Bug c++/50586] Template argument of type "pointer to function" of a template class causes usage error if template is instantiated with pointer-to-private-static-member-function
  2011-10-01  9:35 [Bug c++/50586] New: Template argument of type "pointer to function" of a template class causes usage error if template is instantiated with pointer-to-private-static-member-function mouchtaris at gmail dot com
@ 2011-10-01 15:18 ` daniel.kruegler at googlemail dot com
  2011-10-01 22:34 ` paolo.carlini at oracle dot com
  2013-06-16  9:03 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2011-10-01 15:18 UTC (permalink / raw)
  To: gcc-bugs

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

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> 2011-10-01 15:18:04 UTC ---
The problem also occurs with gcc 4.7.0 20110924 (experimental)


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

* [Bug c++/50586] Template argument of type "pointer to function" of a template class causes usage error if template is instantiated with pointer-to-private-static-member-function
  2011-10-01  9:35 [Bug c++/50586] New: Template argument of type "pointer to function" of a template class causes usage error if template is instantiated with pointer-to-private-static-member-function mouchtaris at gmail dot com
  2011-10-01 15:18 ` [Bug c++/50586] " daniel.kruegler at googlemail dot com
@ 2011-10-01 22:34 ` paolo.carlini at oracle dot com
  2013-06-16  9:03 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-10-01 22:34 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011-10-01
                 CC|mouchtaris at gmail dot com |
     Ever Confirmed|0                           |1

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-10-01 22:33:38 UTC ---
Confirmed of course. Doesn't seem a regression.


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

* [Bug c++/50586] Template argument of type "pointer to function" of a template class causes usage error if template is instantiated with pointer-to-private-static-member-function
  2011-10-01  9:35 [Bug c++/50586] New: Template argument of type "pointer to function" of a template class causes usage error if template is instantiated with pointer-to-private-static-member-function mouchtaris at gmail dot com
  2011-10-01 15:18 ` [Bug c++/50586] " daniel.kruegler at googlemail dot com
  2011-10-01 22:34 ` paolo.carlini at oracle dot com
@ 2013-06-16  9:03 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-06-16  9:03 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Dup.

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


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

end of thread, other threads:[~2013-06-16  9:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-01  9:35 [Bug c++/50586] New: Template argument of type "pointer to function" of a template class causes usage error if template is instantiated with pointer-to-private-static-member-function mouchtaris at gmail dot com
2011-10-01 15:18 ` [Bug c++/50586] " daniel.kruegler at googlemail dot com
2011-10-01 22:34 ` paolo.carlini at oracle dot com
2013-06-16  9:03 ` 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).