Asm bug in C++ templates

Hidvegi hzoli@austin.ibm.com
Mon Nov 15 16:56:00 GMT 1999


The following program produces bad assembly output with

g++ -O3 -S foo.C

---------------------- CUT HERE ----------------------
template <class T>
class tmpl {
public:
    static int foo(void);
};

template <class T>
int
tmpl<T>::foo(void)
{
  int g;

  __asm__ ("bad" "bad" : "=r" (g));

  return g;
}

template tmpl<int>;
---------------------- CUT HERE ----------------------

The "badbad" string is missing from the assembly, or it is replaced by
junk.  I tested this on rs6k and i386 with:

gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
gcc version 2.95.2 19991024 (release)  (on i386 RedHat 6.0 and rs6k AIX4.3.2)
gcc version 2.95 19990728 (release) (on rs6k aix 4.3.2)

Note that g++ -O2 works fine.

Zoli


More information about the Gcc-bugs mailing list