http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57546
Bug ID: 57546 Summary: templated gnu multiversion function pointer returns wrong value Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mib.bugzilla at gmail dot com /rdrive/ref/gcc/bin/g++48 fum.cpp -std=c++0x -bash-4.1$ ./a.out FAILED i:0 j:0x80499c6 -bash-4.1$ cat fum.cpp template <typename T> class Foo { public: /* Default version of foo. */ __attribute__ ((target("default"))) T foo () { return 0; } /* corei7 version of foo. */ __attribute__ ((target("arch=corei7"))) T foo () { return 0; } T (Foo::*p)() = &Foo::foo; // pointer to member }; #include <stdio.h> int main () { Foo<int> f; int i = f.foo(); int j = (f.*(f.p))(); // pointer to member call if (i==j && j==0) { printf("PASSED\n"); return 0; } else { printf("FAILED i:%d j:0x%x\n", i, j); return -1; } } -bash-4.1$ /rdrive/ref/gcc/bin/g++48 -v Using built-in specs. COLLECT_GCC=/rdrive/ref/gcc/4.8.1/rhel60/x86/bin/g++ COLLECT_LTO_WRAPPER=/site/spt/rdrive/ref/gcc/4.8.1/rhel60/x86/bin/../libexec/gcc/i686-pc-linux-gnu/4.8.1/lto-wrapper Target: i686-pc-linux-gnu Configured with: /rusers/sys_cron/grab_gcc/downloads_rel/4.8.1/gcc-4.8.1/configure --prefix=/rdrive/ref/gcc/4.8.1/rhel60/x86 --enable-languages=c,c++,objc,fortran --disable-multilib --target=i686-pc-linux-gnu --disable-bootstrap --enable-decimal-float --with-gmp=/rusers/sys_cron/grab_gcc/downloads_rel/lib/x86 --with-mpfr=/rusers/sys_cron/grab_gcc/downloads_rel/lib/x86 --with-mpc=/rusers/sys_cron/grab_gcc/downloads_rel/lib/x86 Thread model: posix gcc version 4.8.1 (GCC)