[cc65] bug report: pass-by-value of structs destroys stack

From: Sidney Cadot <cadot1science-and-technology.nl>
Date: 2005-11-29 22:56:40
Hi Uz,

.... Passing a struct as a function parameter destroys the stack -  
probably a simple offset problem.

Below is a program that manifests the problem in v2.11.0.

Best regards, Sidney

/********* code starts here *******/

#include <stdio.h>

struct TestStruct {
   int a;
   int b;
};

void testfunc(struct TestStruct ts)
{
     printf("ts.a = %d, ts.b = %d\n", ts.a, ts.b);
}

struct TestStruct tm;

int main(void)
{
     int x;

     x = 1;

     tm.a = 2;
     tm.b = 3;

     /* remove the following line to make the bug disappear. */
     testfunc(tm);

     printf("x = %d\n", x);

     while(1);
     return 0;
}

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Nov 29 22:56:47 2005

This archive was generated by hypermail 2.1.8 : 2005-11-29 22:56:51 CET