🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Paul Eggert Mon, 02 Nov 1992 22:31
LDBL_MIN etc should be constant exprs (GCC 2.3.1, enquire 4.3, sparc)
#50
Author: Paul Eggert
Date: Mon, 02 Nov 1992 22:31
50 lines
2340 bytes
The program

	#include <float.h>
	long double x = LDBL_MIN;

worked with GCC 2.2.2 (sparc, SunOS 4.1.2), but GCC 2.3.1 instead says:

	t.c:2: initializer element for `x' is not constant

The C Standard allows this diagnostic, since LDBL_MIN need not be a constant
expression; but it would be nicer if LDBL_MIN were a constant expression like
the other _MIN constants.  The problem is that enquire 4.3, as distributed
with GCC 2.3.1, generates a line like

	#define LDBL_MIN (__extension__ ((union __convert_long_double) {0x100000, 0x0, 0x0, 0x0}).__convert_long_double_d)

(which is not a constant expression) because long double I/O is not supported
on a sparc.  However, enquire can easily generate a constant here, since long
double and double are the same type on a sparc.  The following patch causes
enquire.c to avoid the funny union if long double is equivalent to double, so
that it generates the following instead:

	#define LDBL_MIN 2.2250738585072014e-308L


===================================================================
RCS file: RCS/enquire.c,v
retrieving revision 4.3.1.1
retrieving revision 4.3.1.2
diff -c -r4.3.1.1 -r4.3.1.2
*** enquire.c	1992/11/02 21:49:19	4.3.1.1
--- enquire.c	1992/11/02 22:26:30	4.3.1.2
***************
*** 824,830 ****
  	if (stdc) {
  #ifdef NO_LONG_DOUBLE_IO
  		static int union_defined = 0;
! 		if (!strcmp(sort, "LDBL")) {
  			if (!union_defined) {
  				printf("#ifndef __LDBL_UNION__\n");
  				printf("#define __LDBL_UNION__\n");
--- 824,831 ----
  	if (stdc) {
  #ifdef NO_LONG_DOUBLE_IO
  		static int union_defined = 0;
! 		if (sizeof(double) != sizeof(Long_double)
! 		    && !strcmp(sort, "LDBL")) {
  			if (!union_defined) {
  				printf("#ifndef __LDBL_UNION__\n");
  				printf("#define __LDBL_UNION__\n");
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