assigning a pointer to linked list to stuct element, changes list

Julian Cooling jmc@mail.dcbt.com.au
Wed Nov 17 00:13:00 GMT 1999


Hi,

I was compiling my C program on a computer:

$ uname -a 
Linux jack 2.2.5-22 #1 Wed Jun 2 08:45:51 EDT 1999 i586 unknown
$ cat /etc/redhat-release 
Red Hat Linux release 6.0 (Hedwig)
$ date
Wed Nov 17 19:53:31 CST 1999
$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)

I used -g every time but the bug is there without it.

The bug appears when I assign a pointer (which is first element in a linked 
list) to a pointer of the same type.  The second and succeeding elements of 
the list change to point to the first (i.e. the list becomes a loop).

I included 5 attachments.

1) The C file (edited down severely)
2) The .h file (it now lives in the same directory as the C file)
3) The output of gcc -E
4) The output with the bug
5) The output with the bug fixed (by uncommenting a line in the .h file)

I hope these all help.  Sorry about the quality of the C code - bug tracking 
via code is not pretty and gdb wasn't much help in this case.

regards,

Julian Cooling


More information about the Gcc-bugs mailing list