Article View: gnu.gcc.bug
Article #39float.h mixes up unsigned and int (GCC 2.3.1, enquire 4.3, sparc)
From: Paul Eggert
Date: Mon, 02 Nov 1992 22:41
Date: Mon, 02 Nov 1992 22:41
55 lines
2719 bytes
2719 bytes
enquire.c 4.3 (distributed with GCC 2.3.1) generates output of the form
union __convert_long_double {
int __convert_long_double_i[4];
long double __convert_long_double_d;
};
#define LDBL_MAX (__extension__ ((union __convert_long_double) {0x7fefffff, 0xffffffff, 0x0, 0x0}).__convert_long_double_d)
Strictly speaking, it violates the C Standard to assign a number like
0xfffffff to a typical 32-bit int, since 0xfffffff is a huge unsigned value
that is too big for an int. This causes warnings in some implementations.
The following patch causes enquire.c to use `unsigned' instead of `int',
avoiding the problem.
===================================================================
RCS file: RCS/enquire.c,v
retrieving revision 4.3.1.2
retrieving revision 4.3.1.3
diff -c -r4.3.1.2 -r4.3.1.3
*** enquire.c 1992/11/02 22:26:30 4.3.1.2
--- enquire.c 1992/11/02 22:33:28 4.3.1.3
***************
*** 830,836 ****
printf("#ifndef __LDBL_UNION__\n");
printf("#define __LDBL_UNION__\n");
printf("union __convert_long_double {\n");
! printf(" int __convert_long_double_i[4];\n");
printf(" long double __convert_long_double_d;\n");
printf("};\n");
printf("#endif\n");
--- 830,836 ----
printf("#ifndef __LDBL_UNION__\n");
printf("#define __LDBL_UNION__\n");
printf("union __convert_long_double {\n");
! printf(" unsigned __convert_long_double_i[4];\n");
printf(" long double __convert_long_double_d;\n");
printf("};\n");
printf("#endif\n");
***************
*** 906,912 ****
char *fake_f_rep(type, val) char *type; Long_double val; {
static char buf[1024];
! union { int i[4]; Long_double ld;} u;
u.i[0] = u.i[1] = u.i[2] = u.i[3] = 0;
u.ld = val;
sprintf(buf, "(__extension__ ((union __convert_long_double) {0x%x, 0x%x, 0x%x, 0x%x}).__convert_long_double_d)",
--- 906,912 ----
char *fake_f_rep(type, val) char *type; Long_double val; {
static char buf[1024];
! union { unsigned i[4]; Long_double ld;} u;
u.i[0] = u.i[1] = u.i[2] = u.i[3] = 0;
u.ld = val;
sprintf(buf, "(__extension__ ((union __convert_long_double) {0x%x, 0x%x, 0x%x, 0x%x}).__convert_long_double_d)",
Technical Details
Message-ID:
<9211022241.AA04331@farside.twinsun.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!noc.near.net!hri.com!spool.mu.edu!caen!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!twinsun.COM!eggertShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!noc.near.net!hri.com!spool.mu.edu!caen!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!twinsun.COM!eggert From: eggert@twinsun.COM (Paul Eggert) Newsgroups: gnu.gcc.bug Subject: float.h mixes up unsigned and int (GCC 2.3.1, enquire 4.3, sparc) Message-ID: <9211022241.AA04331@farside.twinsun.com> Date: 2 Nov 92 22:41:46 GMT Sender: gnulists@ai.mit.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 55 Approved: bug-gcc@prep.ai.mit.edu