Thread View: gnu.gcc.bug
1 messages
1 total messages
Started by Johnson Earls
Mon, 27 Jul 1992 19:09
GCC 2.2.2 on a Sun4 (Sparc) : union getting trashed in func call
Author: Johnson Earls
Date: Mon, 27 Jul 1992 19:09
Date: Mon, 27 Jul 1992 19:09
107 lines
2747 bytes
2747 bytes
Version: gcc 2.2.2
Source code:
-------- snip snip --------
typedef union atomVal
{
char c;
long l;
double d;
void *p;
} atomVal;
typedef struct object
{
struct object *parent;
int count;
int *methods;
char *name;
long size;
} *object;
typedef struct AtomData
{
atomVal value;
} *AtomData;
typedef struct Atom
{
struct object info;
struct AtomData data;
} *Atom;
struct Atom test_atom_struct;
Atom test_atom = &test_atom_struct;
void atom_set(Atom h, atomVal v)
{
h->data.value = v;
}
main()
{
atomVal av;
av.p = &test_atom;
atom_set(test_atom, av);
}
-------- snip snip --------
Compile line: gcc -g test.c
Machine: Sun: SPARCserver 690MP running SunOS 4.1.2
Also: SPARC IPC running SunOS 4.1.2
Configure options: ./configure sun4-sunos4.1.2
Modifications to GCC: None
Description:
The union variable `av' does not get passed to the subroutine
correctly.
Typescript of the problem:
Script started on Mon Jul 27 12:03:59 1992
%%% gcc -v
Reading specs from /usr/local/lib/gcc-lib/sun4-sunos4.1.2/2.2.2/specs
gcc version 2.2.2
%%% gcc -g test.c
%%% gdb a.out
GDB is free software and you are welcome to distribute copies of it
under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.4, Copyright 1991 Free Software Foundation, Inc...
(gdb) b main
Breakpoint 1 at 0x22bc: file test.c, line 42.
(gdb) run
Starting program: /home/cscstd/ijkl/jearls/Work/a.out
Breakpoint 1, main () at test.c:42
42 av.p = &test_atom;
(gdb) s
44 atom_set(test_atom, av);
(gdb) print av
$1 = {c = 0 '\000', l = 16552, d = 3.5123274336104573e-310, p = 0x40a8}
(gdb) s
atom_set (h=0x40c0, v={c = 17 '\021', l = 289411200,
d = 1.3562482849288595e-225, p = 0x11401080}) at test.c:35
35 h->data.value = v;
(gdb) print v
$2 = {c = 17 '\021', l = 289411200, d = 1.3562482849288595e-225,
p = 0x11401080}
(gdb) q
%%% exit
script done on Mon Jul 27 12:04:33 1992
If this is part of ANSI C, or isn't a bug for some other reason, sorry
for the inconvenience.
- John
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