C compiler bcc struct passing fails
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
linux86 (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
C compiler bcc copies structs and returns structs correctly but fails to pass them to functions. From checking it turns out that the generated code calls _memcpy with the wrong parameters. For example, this is the generated assembly which should pass a 6-byte struct to a function.
! Debug: list struct composite original = [S+$14-$C] (used reg = )
add sp,*-6
mov ax,sp <--- presumably the target address
mov ax,*6 <--- gets overwritten by the size of the struct
push ax <--- push the size of the struct
lea bx,-$A[bp]
push bx <--- push the source address
push ax <--- should be the target address
call _memcpy
add sp,*6
ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: bcc 0.16.17-3.1ubuntu3
ProcVersionSign
Uname: Linux 3.13.0-30-generic i686
ApportVersion: 2.14.1-0ubuntu3.2
Architecture: i386
Date: Sun Jan 4 22:58:22 2015
ProcEnviron:
SHELL=/bin/bash
TERM=ansi
PATH=(custom, user)
LANG=en_GB.utf8
XDG_RUNTIME_
SourcePackage: linux86
UpgradeStatus: Upgraded to trusty on 2014-06-20 (198 days ago)
Attached a short program which can be compiled in order to see the problem. Compile with
bcc -ansi -S struct_pass.c
Then scroll down the resulting assembly file struct_pass.s to get past the comments. On my system the errant code began at line 235.