delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2008/09/26/15:48:24

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Recipient: djgpp-workers AT delorie DOT com
X-Authenticated: #27081556
X-Provags-ID: V01U2FsdGVkX1+4WlIqF3K4Gtabz5WLKtbBuggDiVFwI7sQCk4veD
0TZVO8YjS02rYp
Message-ID: <000501c92010$b9297fc0$2202a8c0@computername>
From: "Juan Manuel Guerrero" <juan DOT guerrero AT gmx DOT de>
To: <djgpp-workers AT delorie DOT com>
Subject: Fix for "dereferencing type-punned pointer will break strict-aliasing rules" error
Date: Fri, 26 Sep 2008 21:47:34 +0200
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
X-Y-GMX-Trusted: 0
X-FuHaFi: 0.5
Reply-To: djgpp-workers AT delorie DOT com

While I was trying to compile djgpp sources from the CVS tree with gcc 4.3.2,
a couple of warnings like this:

gcc ... -c ef_scalb.c
cc1.exe: warnings being treated as errors
ef_scalb.c: In function '__ieee754_scalbf':
ef_scalb.c:46: error: dereferencing type-punned pointer will break strict-aliasing rules

appeared.  The value to pass to the macros finitef, isnanf, etc. must be the
long type union member and not float type one to fix this issue.


Regards,
Juan M. Guerrero




Index: src/libm/math/ef_scalb.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libm/math/ef_scalb.c,v
retrieving revision 1.2
diff -p -U5 -r1.2 ef_scalb.c
--- src/libm/math/ef_scalb.c 29 Jun 2003 14:24:17 -0000 1.2
+++ src/libm/math/ef_scalb.c 26 Sep 2008 19:42:36 -0000
@@ -41,11 +41,11 @@
  
  ux.f = x;
  ufn.f = fn;
  
  if (isnanf(ux.l)||isnanf(ufn.l)) return x*fn;
- if (!finitef(ufn.f)) {
+ if (!finitef(ufn.l)) {
      if(fn>(float)0.0) return x*fn;
      else       return x/(-fn);
  }
  if (rintf(fn)!=fn) return (fn-fn)/(fn-fn);
 #if INT_MAX > 65000
Index: src/libm/math/wf_fmod.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libm/math/wf_fmod.c,v
retrieving revision 1.3
diff -p -U5 -r1.3 wf_fmod.c
--- src/libm/math/wf_fmod.c 20 Jul 2003 10:06:54 -0000 1.3
+++ src/libm/math/wf_fmod.c 26 Sep 2008 19:42:36 -0000
@@ -36,11 +36,11 @@
  
  ux.f = x;
  uy.f = y;
 
  z = __ieee754_fmodf(x,y);
- if(_LIB_VERSION == _IEEE_ ||isnanf(uy.f)||isnanf(ux.f)) return z;
+ if(_LIB_VERSION == _IEEE_ ||isnanf(uy.l)||isnanf(ux.l)) return z;
  if(y==(float)0.0) {
   /* fmodf(x,0) */
          return (float)__kernel_standard((double)x,(double)y,127);
  } else
      return z;
Index: src/libm/math/wf_gamma.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libm/math/wf_gamma.c,v
retrieving revision 1.3
diff -p -U5 -r1.3 wf_gamma.c
--- src/libm/math/wf_gamma.c 20 Jul 2003 10:06:54 -0000 1.3
+++ src/libm/math/wf_gamma.c 26 Sep 2008 19:42:36 -0000
@@ -34,11 +34,11 @@
  ux.f = x;
 
         y = __ieee754_gammaf_r(x,&signgam);
   uy.f = y;
         if(_LIB_VERSION == _IEEE_) return y;
-        if(!finitef(uy.f)&&finitef(ux.f)) {
+        if(!finitef(uy.l)&&finitef(ux.l)) {
             if(floorf(x)==x&&x<=(float)0.0)
          /* gammaf pole */
                 return (float)__kernel_standard((double)x,(double)x,141);
             else
          /* gammaf overflow */
Index: src/libm/math/wrf_gamma.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libm/math/wrf_gamma.c,v
retrieving revision 1.3
diff -p -U5 -r1.3 wrf_gamma.c
--- src/libm/math/wrf_gamma.c 20 Jul 2003 10:06:54 -0000 1.3
+++ src/libm/math/wrf_gamma.c 26 Sep 2008 19:42:36 -0000
@@ -37,11 +37,11 @@
  ux.f = x;
 
         y = __ieee754_gammaf_r(x,signgamp);
   uy.f = y;
         if(_LIB_VERSION == _IEEE_) return y;
-        if(!finitef(uy.f)&&finitef(ux.f)) {
+        if(!finitef(uy.l)&&finitef(ux.l)) {
             if(floorf(x)==x&&x<=(float)0.0)
          /* gammaf pole */
                 return (float)__kernel_standard((double)x,(double)x,141);
             else
          /* gamma overflow */
Index: src/libm/math/wrf_lgamma.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libm/math/wrf_lgamma.c,v
retrieving revision 1.3
diff -p -U5 -r1.3 wrf_lgamma.c
--- src/libm/math/wrf_lgamma.c 20 Jul 2003 10:06:54 -0000 1.3
+++ src/libm/math/wrf_lgamma.c 26 Sep 2008 19:42:36 -0000
@@ -38,11 +38,11 @@
  
         y = __ieee754_lgammaf_r(x,signgamp);
  uy.f = y;
 
         if(_LIB_VERSION == _IEEE_) return y;
-    if(!finitef(uy.f)&&finitef(ux.f)) {
+    if(!finitef(uy.l)&&finitef(ux.l)) {
             if(floorf(x)==x&&x<=(float)0.0)
          /* lgamma pole */
                 return (float)__kernel_standard((double)x,(double)x,115);
             else
          /* lgamma overflow */

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019