public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* bug with asm statment in egcs-1.0.2
@ 1998-04-21 19:10 Peter Barada
  1998-04-22  4:19 ` Jeffrey A Law
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Barada @ 1998-04-21 19:10 UTC (permalink / raw)
  To: egcs; +Cc: pbarada

I found a bug in reg-stack.c:constrain_asm_operands when compiling the
following asm statment for i386:

  asm volatile  (".data;\t.align 4;.LP" "DLbuildtrap"
    ";\t.long 0;.text;\tmovel $.LP" "DLbuildtrap" ",%%edx;\tcall mcount"
    : /* No outputs */
    : /* No inputs */
    : "eax", "edx", "ecx", "st",
      "st(1)","st(2)","st(3)","st(4)","st(5)","st(6)","st(7)" );

with the flags '-O -fstrength-reduce -fsigned-char'

reg-stack.c:constrain_asm_operands() contains the following:

  for (j = 0; j < n_operands; j++)
    constraints[j] = operand_constraints[j];

  /* Compute the number of alternatives in the operands.  reload has
     already guaranteed that all operands have the same number of
     alternatives.  */

  n_alternatives = 1;
  for (q = constraints[0]; *q; q++)
    n_alternatives += (*q == ',');


But when n_operands is zero, then constraints[0] is bogus and it
SIGSEGVs.

If you add a test for n-operands before the for (q = contraints[0]; *q; q++)
then everything is fine...

  n_alternatives = 1;
  if (n_operands)
    for (q = constraints[0]; *q; q++)
      n_alternatives += (*q == ',');

-- 
Peter Barada                            pbarada@wavemark.com
Wizard                                  781-270-7098 x226
WaveMark Technologies, Inc.             781-270-0193 (fax)

"Real men know that you should never attempt to accomplish with words
what you can do with a flame thrower" --Bruce Ferstein

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

end of thread, other threads:[~1998-04-24 10:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-04-21 19:10 bug with asm statment in egcs-1.0.2 Peter Barada
1998-04-22  4:19 ` Jeffrey A Law
1998-04-22  8:31   ` H.J. Lu
1998-04-22 18:40     ` Jeffrey A Law
1998-04-23  2:49       ` Wolfram Gloger
1998-04-23 10:41         ` Joe Buck
1998-04-23 21:12           ` Michael Alan Dorman
1998-04-24  6:54             ` Toon Moene
1998-04-24 10:34               ` Jeffrey A Law
1998-04-23 13:31         ` Jeffrey A Law

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