https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68098
Bug ID: 68098 Summary: Function multiversioning causes segfaults when used for member functions Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: egor.kochetov at intel dot com Target Milestone: --- Here is the source that triggers runtime segmentation fault when compiled by `g++` versions 4.9 through 6.0 trunk. #include <cstdio> class Foo { public: /* Default version of foo. */ __attribute__ ((target("default"))) int foo () { return 0; } /* SSSE3 version of foo. */ __attribute__ ((target("ssse3"))) int foo () { return 0; } }; int main () { Foo f; typedef int (Foo::* funcptr)(); funcptr fp = &Foo::foo; j = (f.*fp)(); //< segfault here // f.foo(); //< works as expected printf ("all good\n"); return 0; } The problem occurs only if the version function is accessed by a member-function ponter, direct function call works as expected. Compilation and target platforms are Linux 64 bit, -O0 throug -Ofast, -m32 or -m64.