public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "sgk at troutmask dot apl.washington.edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/113152] Fortran 2023 half-cycle trigonometric functions
Date: Sun, 21 Jan 2024 23:52:03 +0000	[thread overview]
Message-ID: <bug-113152-4-zmkxKeQfHq@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-113152-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113152

--- Comment #14 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Sun, Jan 21, 2024 at 09:52:39PM +0000, anlauf at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113152
> 
> I think that you cannot do
> 
> +  if (MPFR_HALF_CYCLE)
> 
> you really must use
> 
> #if MPFR_HALF_CYCLE
> 

#include <stdio.h>
#include "mpfr.h"

#define MPFR_HALF_CYCLE (MPFR_VERSION_MAJOR * 100 + MPFR_VERSION_MINOR >= 402)

int
main(void)
{
   if (MPFR_HALF_CYCLE)
      printf("here\n");
   else
      printf("there\n");
   return (0);
}

% cc -o z -I/usr/local/include a.c && ./z
here
% cc -E -I/usr/local/include a.c | grep -v mpfr_ | grep -v gmp | cat -s
...
int
main(void)
{
   if ((4 * 100 + 2 >= 402))
      printf("here\n");
   else
      printf("here\n");
   return (0);
}

Are you sure that your testing is finding the right mpfr.h?
If I add 

#ifdef MPFR_VERSION_MAJOR
#undef MPFR_VERSION_MAJOR
#endif 
#define MPFR_VERSION_MAJOR 3

above the define for MPFR_HALF_CYCLE in simplify.cc, it compiles
for me.  With this simple program

   real, parameter :: x = cospi(1.)
   print *,x
   end

gdb ends up in the else { } branch.

Breakpoint 1, gfc_simplify_cospi (x=0x803e24b60)
    at ../../gcc/gcc/fortran/simplify.cc:2085
2085      result = gfc_get_constant_expr (x->ts.type, x->ts.kind, &x->where);
(gdb) n
2101          mpfr_inits2 (2 * mpfr_get_prec (x->value.real), cs, n, r, NULL);

  parent reply	other threads:[~2024-01-21 23:52 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-27  1:24 [Bug fortran/113152] New: " kargl at gcc dot gnu.org
2023-12-27  1:25 ` [Bug fortran/113152] " kargl at gcc dot gnu.org
2023-12-27  1:26 ` kargl at gcc dot gnu.org
2023-12-27  1:27 ` kargl at gcc dot gnu.org
2023-12-27  1:28 ` kargl at gcc dot gnu.org
2023-12-27 10:20 ` mikael at gcc dot gnu.org
2023-12-27 19:16 ` kargl at gcc dot gnu.org
2023-12-27 23:51 ` kargl at gcc dot gnu.org
2023-12-27 23:56 ` kargl at gcc dot gnu.org
2023-12-27 23:57 ` kargl at gcc dot gnu.org
2023-12-29 20:08 ` kargl at gcc dot gnu.org
2023-12-29 20:34 ` anlauf at gcc dot gnu.org
2023-12-30  0:56 ` sgk at troutmask dot apl.washington.edu
2024-01-20 19:12 ` kargl at gcc dot gnu.org
2024-01-21 21:52 ` anlauf at gcc dot gnu.org
2024-01-21 23:52 ` sgk at troutmask dot apl.washington.edu [this message]
2024-01-22  0:10 ` kargl at gcc dot gnu.org
2024-01-22 17:35 ` anlauf at gcc dot gnu.org
2024-01-22 18:06 ` sgk at troutmask dot apl.washington.edu
2024-01-22 18:22 ` anlauf at gcc dot gnu.org

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=bug-113152-4-zmkxKeQfHq@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).