Hi, when doing 'register int val asm("rx")' in a template function the explicit register allocation is ignored and val is given an arbitrary register without any notice. The following test shows that the asm-statement is ignored. class X { public: template <typename T> int func_template(int *x); int no_template(int *x); }; template <typename T> int X::func_template(int *x) { register int val asm("doesn't matter what's in here"); asm volatile("mov %0, %0" : "=r" (val) : "0" (x)); return val; } int X::no_template(int *x) { register int val asm("edx"); asm volatile("mov %0, %0" : "=r" (val) : "0" (x)); return int(val); } #include <cstdio> int main(void) { X x; int y; printf("%d %d\n", x.no_template(&y), x.func_template<int>(&y)); return 0; } A normal function works as expected. We initially found this on a ARM target but it's the same on x86. I get the same results with various versions of native and cross compilers of 3.4, 4.1, 4.2, 4.3 and trunk.
*** This bug has been marked as a duplicate of 33661 ***