https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124682
--- Comment #3 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
The two MPC versions disagree on the sign of the result of mpc_pow() of
(gdb) p m0
$4 = {{re = {{_mpfr_prec = 53, _mpfr_sign = -1, _mpfr_exp = 2,
_mpfr_d = 0x396f9b8}}, im = {{_mpfr_prec = 53, _mpfr_sign = 1,
_mpfr_exp = -9223372036854775807, _mpfr_d = 0x396fb78}}}}
(gdb) p m1
$5 = {{re = {{_mpfr_prec = 53, _mpfr_sign = -1, _mpfr_exp = 2,
_mpfr_d = 0x396fb98}}, im = {{_mpfr_prec = 53, _mpfr_sign = -1,
_mpfr_exp = -9223372036854775807, _mpfr_d = 0x396fbb8}}}}
I made some LLM output an example to demonstrate the difference:
#include <stdio.h>
#include <mpc.h> // GNU MPC header
int main(void) {
// Set precision to 256 bits
mpc_t base, exponent, temp, result;
mpc_init2(base, 256);
mpc_init2(exponent, 256);
mpc_init2(temp, 256);
mpc_init2(result, 256);
// Base = -2 (real only, imaginary part = 0)
mpc_set_si_si(base, -2, 0, MPC_RNDNN);
// temp = (3 + 0i)
mpc_set_si_si(temp, 3, 0, MPC_RNDNN);
// exponent = -(3 + 0i)
mpc_neg(exponent, temp, MPC_RNDNN);
// Compute result = base ^ exponent
mpc_pow(result, base, exponent, MPC_RNDNN);
// Print result with 20 decimal places
printf("(-2)^-(3 + 0i) = ");
mpc_out_str(stdout, 10, 20, result, MPC_RNDNN);
printf("\n");
// Clear memory
mpc_clear(base);
mpc_clear(exponent);
mpc_clear(temp);
mpc_clear(result);
return 0;
}
With MPC 1.4 it outputs (-2)^-(3 + 0i) = (-1.2500000000000000000e-1 0), but
with MPC 1.3.1 it outputs (-2)^-(3 + 0i) = (-1.2500000000000000000e-1 -0).