This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Invalid assembly language generated


The following short source file appears to generate invalid assembly
language.  I'm using egcs 1.0.2 and 1.0.3 on linux (both libc5 and
libc6) on a pentium and a pentium II with binutils 2.7.0.9 or 2.8.1.0
(both configurations have the same problem).  No modifications were made
to egcs, and the only configuration option specified was --prefix=....

------------------------------------------------------------------------
const int u_um = 01;
const int u_um2 = 2*u_um;

template <int unit_code_param>
class float_with_units
{
public:
  float_with_units(float init_val = 0) : val(init_val) {}
  float_with_units(const float_with_units &rhs) : val(rhs.val) {}

  float val;
};

template <int T1_units, int T2_units> float_with_units<T1_units+T2_units>
operator*(const float_with_units<T1_units> &arg1,
	  const float_with_units<T2_units> &arg2) {
  return arg1.val * arg2.val;
}

typedef float_with_units<u_um> units_um;
typedef float_with_units<u_um2> units_um2;
static const units_um um(1);
static const units_um2 um2(um*um);
------------------------------------------------------------------------
% uname -a
Linux paul-ppp 2.0.32 #1 Tue May 12 14:05:31 PDT 1998 i586 unknown
% g++ -v
Reading specs from /usr/local/packages/egcs-1.0.3a/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.90.29/specs
gcc version egcs-2.90.29 980515 (egcs-1.0.3 release)
% as -v
GNU assembler version 2.8.1 (i686-pc-linux-gnu), using BFD version linux-2.8.1.0.1
% g++ bug_invalid_asm.cxx
/tmp/cca00173.s: Assembler messages:
/tmp/cca00173.s:65: Error: Rest of line ignored. First ignored character is `*'.
/tmp/cca00173.s:66: Error: ignoring unrecognized symbol type ""
/tmp/cca00173.s:66: Error: Rest of line ignored. First ignored character is `*'.
/tmp/cca00173.s:67: Error: invalid character '_' in opcode
/tmp/cca00173.s:98: Error: expected comma after name `__ml__H2i1i1_RCt16float_with_units1iY01RCt16float_with_units1iY11_t16float_with_units1i' in .size directive
/tmp/cca00173.s:98: Error: Rest of line ignored. First ignored character is `*'.
%
------------------------------------------------------------------------
Some lines from the resulting assembly language code are:

    39	__t16float_with_units1i2RCt16float_with_units1i2:
    40	.LFB2:
    41		pushl %ebp
    42	.LCFI2:
    43		movl %esp,%ebp
    44	.LCFI3:
    45		pushl %ebx
    46	.LCFI4:
    47		movl 8(%ebp),%ecx
    48		movl 12(%ebp),%edx
    49		movl (%edx),%ebx
    50		movl %ebx,(%ecx)
    51	.L5:
    52		movl %ecx,%eax
    53		jmp .L4
    54		.align 4
    55	.L4:
    56		movl -4(%ebp),%ebx
    57		movl %ebp,%esp
    58		popl %ebp
    59		ret
    60	.LFE2:
    61	.Lfe2:
    62		.size	 __t16float_with_units1i2RCt16float_with_units1i2,.Lfe2-__t16float_with_units1i2RCt16float_with_units1i2
    63	.section	.gnu.linkonce.t.__ml__H2i1i1_RCt16float_with_units1iY01RCt16float_with_units1iY11_t16float_with_units1i *0,"ax",@progbits
    64		.align 4
    65		.weak	__ml__H2i1i1_RCt16float_with_units1iY01RCt16float_with_units1iY11_t16float_with_units1i *0
=============== Problem here, with the '* 0'
    66		.type	 __ml__H2i1i1_RCt16float_with_units1iY01RCt16float_with_units1iY11_t16float_with_units1i *0,@function
=============== problem here, with the '* 0'
    67	__ml__H2i1i1_RCt16float_with_units1iY01RCt16float_with_units1iY11_t16float_with_units1i *0:
=============== problem here, with the '* 0'
    68	.LFB3:
    69		pushl %ebp
    70	.LCFI5:
    71		movl %esp,%ebp
    72	.LCFI6:
    73		pushl %ebx
    74	.LCFI7:
    75		movl 8(%ebp),%ebx
    76		movl 12(%ebp),%eax
    77		movl 16(%ebp),%edx
    78		flds (%eax)
    79		fmuls (%edx)
    80		subl $4,%esp
    81		fstps (%esp)
    82		pushl %ebx
    83	.LCFI8:
    84		call __t16float_with_units1i2f
    85		addl $8,%esp
    86	.LCFI9:
    87		movl %eax,%eax
    88		jmp .L1
    89		.align 4
    90	.L1:
    91		movl %ebx,%eax
    92		movl -4(%ebp),%ebx
    93		movl %ebp,%esp
    94		popl %ebp
    95		ret $4
    96	.LFE3:
    97	.Lfe3:
    98		.size	 __ml__H2i1i1_RCt16float_with_units1iY01RCt16float_with_units1iY11_t16float_with_units1i *0,.Lfe3-__ml__H2i1i1_RCt16float_with_units1iY01RCt16float_with_units1iY11_t16float_with_units1i *0
=============== problem here, with the '* 0'
    99		.local	um2
   100		.comm	um2,4,4
   101		.local	um
   102		.comm	um,4,4


If I change ' *0' into '_0', then it runs through the assembler fine,
and appears to be ok, although I haven't finished enough of the rest of
my program to be sure about that.

-- 
Gary Holt			(213)-740-3397
holt@lnc.usc.edu		http://lnc.usc.edu/~holt/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]