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);

Reply via email to