public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "adam at os dot inf dot tu-dresden dot de" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/36080] New: Register specification ignored in template function. Date: Tue, 29 Apr 2008 17:03:00 -0000 [thread overview] Message-ID: <bug-36080-1407@http.gcc.gnu.org/bugzilla/> (raw) 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
next reply other threads:[~2008-04-29 17:03 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2008-04-29 17:03 adam at os dot inf dot tu-dresden dot de [this message] 2008-04-29 17:10 ` [Bug c++/36080] " pinskia at gcc dot gnu dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-36080-1407@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).