trying to use member functions of classes in the anonymous namespace as
template argument doesn't work.

the following code illustrates this issue:
template <void (*fn)(void)>
void call(void)
{
    fn();
}

namespace
{
struct bar
{
    static void fn(void) {}
};

}

int main()
{
    call<&bar::fn>();
}

it complains:
error: ‘<unnamed>::bar::fn’ is not a valid template argument for type
‘void (*)()’ because function ‘static void<unnamed>::bar::fn()’ has not
external linkage


gcc -v:
[EMAIL PROTECTED]:~$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2
--enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr
--enable-targets=all --enable-checking=release --build=i486-linux-gnu
--host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.2.3 20071014 (prerelease) (Debian 4.2.2-3)


would be great to have this fixed ...


-- 
           Summary: static member function in anonymous namespace can't be
                    used as template argument
           Product: gcc
           Version: 4.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tim at klingt dot org
 GCC build triplet: i486-linux-gnu
  GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu


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

Reply via email to