🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #50

LDBL_MIN etc should be constant exprs (GCC 2.3.1, enquire 4.3, sparc)

#50
From: 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");
Technical Details
Message-ID: <9211022231.AA04304@farside.twinsun.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!portal!lll-winken!iggy.GW.Vitalink.COM!cs.widener.edu!umn.edu!spool.mu.edu!caen!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!twinsun.COM!eggert

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!portal!lll-winken!iggy.GW.Vitalink.COM!cs.widener.edu!umn.edu!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: LDBL_MIN etc should be constant exprs (GCC 2.3.1, enquire 4.3, sparc)
Message-ID: <9211022231.AA04304@farside.twinsun.com>
Date: 2 Nov 92 22:31:15 GMT
Sender: gnulists@ai.mit.edu
Distribution: gnu
Organization: Gnus Not Usenet
Lines: 50
Approved: bug-gcc@prep.ai.mit.edu