🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Paul Eggert Mon, 02 Nov 1992 22:41
float.h mixes up unsigned and int (GCC 2.3.1, enquire 4.3, sparc)
#39
Author: Paul Eggert
Date: Mon, 02 Nov 1992 22:41
55 lines
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)",
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