public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Rainer Orth <ro@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-3605] builtins: Guard builtins.cc against HUGE_VAL and NAN definitions
Date: Wed,  2 Nov 2022 09:53:31 +0000 (GMT)	[thread overview]
Message-ID: <20221102095331.502B63858C55@sourceware.org> (raw)

https://gcc.gnu.org/g:c3299cde4f33121f82a7a25d10c152ac96d2b035

commit r13-3605-gc3299cde4f33121f82a7a25d10c152ac96d2b035
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Wed Nov 2 10:52:59 2022 +0100

    builtins: Guard builtins.cc against HUGE_VAL and NAN definitions
    
    trunk bootstrap recently broke on Solaris like this:
    
    /vol/gcc/src/hg/master/local/gcc/builtins.cc:2104:8: error: pasting
    "CFN_BUILT_IN_" and "(" does not give a valid preprocessing token
     2104 |   case CFN_BUILT_IN_##MATHFN:   \
          |        ^~~~~~~~~~~~~
    /vol/gcc/src/hg/master/local/gcc/builtins.cc:2112:3: note: in expansion of
    macro 'CASE_MATHFN'
     2112 |   CASE_MATHFN(MATHFN)    \
          |   ^~~~~~~~~~~
    /vol/gcc/src/hg/master/local/gcc/builtins.cc:1967:5: note: in expansion of macro 'CASE_MATHFN_FLOATN'
     1967 |     CASE_MATHFN_FLOATN (HUGE_VAL)  \
    
    and similarly for NAN.
    
    It turns out this happens because <math.h> is included at some point,
    which (in <iso/math_c99.h>) defines
    
    While this only happpens on Solaris right now, the same issue would be
    present on other targets when <math.h> gets included somehow.
    
    To avoid this, this patch #undef's both macros.
    
    Bootstrapped without regressions on i386-pc-solaris2.11 and
    sparc-sun-solaris2.11.
    
    2022-11-01  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
    
            gcc:
            * builtins.cc (mathfn_built_in_2): #undef HUGE_VAL, NAN.

Diff:
---
 gcc/builtins.cc | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gcc/builtins.cc b/gcc/builtins.cc
index b359ce2fced..4dc1ca672b2 100644
--- a/gcc/builtins.cc
+++ b/gcc/builtins.cc
@@ -1931,6 +1931,11 @@ mathfn_built_in_2 (tree type, combined_fn fn)
   built_in_function fcodef64x = END_BUILTINS;
   built_in_function fcodef128x = END_BUILTINS;
 
+  /* If <math.h> has been included somehow, HUGE_VAL and NAN definitions
+     break the uses below.  */
+#undef HUGE_VAL
+#undef NAN
+
   switch (fn)
     {
 #define SEQ_OF_CASE_MATHFN			\

                 reply	other threads:[~2022-11-02  9:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221102095331.502B63858C55@sourceware.org \
    --to=ro@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).