public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/36080]  New: Register specification ignored in template function.
@ 2008-04-29 17:03 adam at os dot inf dot tu-dresden dot de
  2008-04-29 17:10 ` [Bug c++/36080] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: adam at os dot inf dot tu-dresden dot de @ 2008-04-29 17:03 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/36080] Register specification ignored in template function.
  2008-04-29 17:03 [Bug c++/36080] New: Register specification ignored in template function adam at os dot inf dot tu-dresden dot de
@ 2008-04-29 17:10 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-04-29 17:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2008-04-29 17:09 -------


*** This bug has been marked as a duplicate of 33661 ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36080


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-04-29 17:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-29 17:03 [Bug c++/36080] New: Register specification ignored in template function adam at os dot inf dot tu-dresden dot de
2008-04-29 17:10 ` [Bug c++/36080] " pinskia at gcc dot gnu dot org

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).