Issue Details (XML | Word | Printable)

Key: PCC-256
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Anders Magnusson
Reporter: Iain Hibbert
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.

using inline function with K&R declaration and -O causing incorrect assembler

Created: 23/Feb/11 09:28 PM   Updated: 26/Feb/11 12:27 PM
Component/s: C frontend
Affects Version/s: None
Fix Version/s: None

Environment: NetBSD/i386

 Description  « Hide
The following code fragment

extern int foo(unsigned char a);

static inline int bar(a)
unsigned char a;
return foo(a);

void baz(void)

when compiled with "pcc -O -c" results in the following error
 /tmp/ctm.01719a: Assembler messages:
 /tmp/ctm.01719a:11: Error: suffix or operands invalid for `movzbl'

and looking at the generated assembler reveals the problem instruction
  movzbl %eax, %ecx

I have seen several instances of this (compiling usr.sbin/racoon on NetBSD) and it is always %eax that is objected to. I don't know i386 assembler but I think this source register is not allowed here.

This problem is related to the K&R declaration, also -xtemps, -xinline and -xdeljumps are all required

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson added a comment - 26/Feb/11 08:38 AM
The register should be an 8-bit register, not 32-bit.

Anders Magnusson added a comment - 26/Feb/11 12:27 PM
Fixed now. The problem was that an argument to an inline function that does not have a prototype do not get correct cast inserted. Now type conversions are enforced whether or not there is a prototype available.

Anders Magnusson added a comment - 26/Feb/11 12:27 PM