🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Steve Linton Wed, 30 Sep 1992 06:35
Structure passing bug
#1235
Author: Steve Linton
Date: Wed, 30 Sep 1992 06:35
40 lines
1205 bytes
A bug seems sometimes to occurr when passing a alrge structure as an argument. 
For example the following does not suceed on a Sun4 under gcc 2.1 or 2.2.2,
at any optimization level.


struct a {int b[7];};

void f(struct a x)
{
  int i;
  for (i=0; i < 7; i++)
    printf("%d\t",x.b[i]);
  putc('\n');
}

main()
{
  struct a y;
  int i;
  for (i = 0; i < 7; i++)
    y.b[i] = i;
  f(y);
}

Under gdb, the argument passed to f appears as 

(gdb) next
17        f(y);
(gdb) print y
$1 = {b = {0, 1, 2, 3, 4, 5, 6}}
(gdb) step
f (x={b = {285216903, 8252, 8256, -16777207, 9, -16777207, -132531200}})
    at test.c:6
6         for (i=0; i < 7; i++)

Is this a known problem? Is there a fix?

	Please reply by mail 

		Steve Linton
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads