[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
I think this is a bug in glibc
From: |
Noel David Torres Taño |
Subject: |
I think this is a bug in glibc |
Date: |
Sat, 09 Dec 2000 /-:40:45 -1300 |
I don't know if this is a bug in glibc, a bug in gcc or
only in my C knowledge, but I think the first because I
think a variable can't have two different values at the
same time.
Using an array in a struct, I found that the same array
element has different values in a printf() call in two
situations.
I expected something like this:
address@hidden ~]$ ./struct
Memory directions and values
0xbffff9ac 80483bb
0xbffff9b0 804960c
0xbffff9b4 8049620
Using listing and listing.array[0] in separate printf()
calls
listing=80483bb listing.array[0]=80483bb
Using listing and listing.array[0] in the same printf()
call
listing=80483bb listing.array[0]=80483bb
address@hidden ~]$
and I found exactly this
address@hidden pruebatablas]$ ./struct
Memory directions and values
0xbffff9ac 80483bb
0xbffff9b0 804960c
0xbffff9b4 8049620
Using listing and listing.array[0] in separate printf()
calls
listing=80483bb listing.array[0]=80483bb
Using listing and listing.array[0] in the same printf()
call
listing=80483bb listing.array[0]=804960c
address@hidden pruebatablas]$
The source code to reproduce the effect is the follow:
/*Program "struct" to reproduce a bug*/
/*Compile with gcc -o struct struct.c*/
#include <stdio.h>
main()
{
struct list
{
int array[2];
int value;
}
listing;
printf("Memory directions and values\n");
printf("%p
%8x\n",&listing.array[0],*(&listing.array[0]));
printf("%p
%8x\n",&listing.array[0]+1,*(&listing.array[0]+1));
printf("%p
%8x\n",&listing.array[0]+2,*(&listing.array[0]+2));
printf("\n");
printf("Using listing and listing.array[0] in separate
printf() calls\n");
printf("listing=%x ",listing);
printf("listing.array[0]=%x\n",listing.array[0]);
printf("Using listing and listing.array[0] in the same
printf() call\n");
printf("listing=%x
listing.array[0]=%x\n",listing,listing.array[0]);
}
Thanks for your attention and time. Im using a
GNU/Linux system (pentium MMX) with Red Hat Linux 6.2,
in which the packets are
address@hidden ~]$ rpm -qa|grep libc
glibc-2.1.3-15
glibc-devel-2.1.3-15
libc-5.3.12-31
address@hidden ~]$
and the compiler is
address@hidden ~]$ gcc --version
egcs-2.91.66
address@hidden ~]$
Again, many thanks for your time and attention.
Sincerely:
Noel David Torres Taño
Spain
address@hidden
Envia gratis tus postales musicales
de Navidad desde http://www.mixmail.com
- I think this is a bug in glibc,
Noel David Torres Taño <=