[Bug c++/36080] New: Register specification ignored in template function.
adam at os dot inf dot tu-dresden dot de
gcc-bugzilla@gcc.gnu.org
Tue Apr 29 17:03:00 GMT 2008
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.
--
Summary: Register specification ignored in template function.
Product: gcc
Version: 4.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: adam at os dot inf dot tu-dresden dot de
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36080
More information about the Gcc-bugs
mailing list