This is the mail archive of the gcc-prs@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]
Other format: [Raw text]

Re: c/7153: bad operands for 'movsbl' error


The following reply was made to PR c/7153; it has been noted by GNATS.

From: "Eric Botcazou" <ebotcazou@libertysurf.fr>
To: "Ben Liblit" <liblit@CS.Berkeley.EDU>
Cc: <gcc-gnats@gcc.gnu.org>
Subject: Re: c/7153: bad operands for 'movsbl' error
Date: Fri, 28 Jun 2002 19:07:14 +0200

 > When fed the C source file given below, gcc generates assembly code
 > which yields the following error message:
 >
 > /var/tmp/ccKc5NSG.s:14: Error: suffix or operands invalid for `movsbl'
 >
 > The assembly code on the line in question is:
 >
 > movsbl %ebx,%eax
 
 It should have been: movsbl %bl,%eax.
 
 > void scale()
 > {
 >   int width;
 >   char bytes;
 >   char *src;
 >
 >   if (width)
 >     {
 >       bytes = *src;
 >       g();
 >       width *= bytes;
 >     }
 >
 >   f(bytes);
 > }
 >
 > I am aware that this code doesn't exactly do anything useful, and even
 > accesses uninitialized variables.
 
 That's actually the "cause" of the problem: one of the optimization passes
 of the compiler (register movement) implicitly expects variables to be set
 before being accessed, here the 'bytes' variable. Writing 'char bytes = 0;"
 lets the problem disappear.
 
 > This fragment is a minimized excerpt from the thousand-line source file in
 > which I originally encountered the bug.
 
 Do you compile it with '-Wall' ? The compiler should then spot (most of) the
 uninitialized automatic variables, thus giving you the opportunity for
 working around the problem.
 
 --
 Eric Botcazou
 ebotcazou@multimania.com
 


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