C compiler bcc struct passing fails

Bug #1407521 reported by James Harris
6
This bug affects 1 person
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
ProcVersionSignature: Ubuntu 3.13.0-30.54-generic 3.13.11.2
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_DIR=<set>
SourcePackage: linux86
UpgradeStatus: Upgraded to trusty on 2014-06-20 (198 days ago)

Revision history for this message
James Harris (james-harris-1-h) wrote :
Revision history for this message
James Harris (james-harris-1-h) wrote :

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.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.