This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
GCC bug report
- From: "Yeh Hong-ming" <hongming at cs dot utexas dot edu>
- To: <gcc-bugs at gcc dot gnu dot org>
- Date: Sun, 16 Nov 2003 11:25:43 -0600
- Subject: GCC bug report
Hi,
I believe that I have found a bug in GCC. The report is enclosed below.
Thanks,
Yeh Hong-ming
Doctoral Student
Department of Computer Science
The University of Texas at Austin
U.S.A.
Version of GCC: gcc version 3.3.1 (cygming special)
Input file:
-------------
#include <stdio.h>
#include <netinet/in.h>
static const float p = 0.9;
void f(long* v) {
long q = htonl(*(long*)&p);
*v = *(long*)&q;
}
void g(char* v) {
long q = htonl(*(long*)&p);
*v = *(char*)&q;
}
int main(){
int x;
f((long*)&x);
x = ntohl(x);
printf("%s\n", *(float*)&x == p ? "OK" : "FAIL");
g((char*)&x);
x = ntohl(x);
/* Expected OK but got FAIL */
printf("%s\n", *(float*)&x == p ? "OK" : "FAIL");
}
-------------
GCC command arguemnts: none. (Simply gcc test.)
Type of machine: Cygwin (DLL version 1.5.3) over Windows XP on Intel Pentium
III
GCC configure/modification: None (Cygwin binary release without change)
Bug behavior: htonl() and ntohl() do not work correctly under certain
combination typecasts. The program is supposed to print two "OK OK", but it
prints "OK FAIL:.