This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/22149] New: func pointer non-type template parm invalid access control


I notice that program1 (the 1st program attached below) fails to compile, but
very similar programs 2 and 3 (attached further below) do. The only difference
being related to how the non-type template parameter is declared "void (*FOOBAR)
()" vs "void FOOBAR ()" vs "void (&FOOBAR) ()". 

/cygdrive/d/users/hill/tmp/daTest$ g++ cat.cpp
cat.cpp: In constructor `foo<FOOBAR>::foo() [with void (*FOOBAR)() = bar::foobar
]':
cat.cpp:12:   instantiated from here
cat.cpp:15: error: `static void bar::foobar()' is private
cat.cpp:7: error: within this context

---------program1--snip--snip---------

template < void (*FOOBAR) () >
class foo {
public:
    foo () { (*FOOBAR) (); }
};

class bar {
public:
    bar () { foo < bar::foobar > tmp; }
private:
    static void foobar ()
    {
    }
};

main ()
{
    bar b;
}
---------program2--snip--snip---------

template < void FOOBAR () >
class foo {
public:
    foo () { FOOBAR (); }
};

class bar {
public:
    bar () { foo < bar::foobar > tmp; }
private:
    static void foobar ()
    {
    }
};

main ()
{
    bar b;
}

--------program3---snip--snip---------

template < void ( &FOOBAR) () >
class foo {
public:
    foo () { FOOBAR (); }
};

class bar {
public:
    bar () { foo < bar::foobar > tmp; }
private:
    static void foobar ()
    {
    }
};

main ()
{
    bar b;
}

-----------snip--snip---------

/cygdrive/d/users/hill/tmp/daTest$ g++ -v
Reading specs from /usr/lib/gcc/i686-pc-cygwin/3.4.4/specs
Configured with: /gcc/gcc-3.4.4/gcc-3.4.4-1/configure --verbose --prefix=/usr --
exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib --man
dir=/usr/share/man --infodir=/usr/share/info --enable-languages=c,ada,c++,d,f77,
java,objc --enable-nls --without-included-gettext --enable-version-specific-runt
ime-libs --without-x --enable-libgcj --disable-java-awt --with-system-zlib --ena
ble-interpreter --disable-libgcj-debug --enable-threads=posix --enable-java-gc=b
oehm --disable-win32-registry --enable-sjlj-exceptions --enable-hash-synchroniza
tion --enable-libstdcxx-debug : (reconfigured)
Thread model: posix
gcc version 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125)

-- 
           Summary: func pointer non-type template parm invalid access
                    control
           Product: gcc
           Version: 3.4.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: johill at lanl dot gov
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-cygwin
  GCC host triplet: i686-pc-cygwin
GCC target triplet: i686-pc-cygwin


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]