qemu-hppa floating point POWER function is incorrect

Host environment

  • Operating system: Gentoo Linux
  • OS/kernel version: Linux 5.10.52-gentoo #1 SMP Thu Aug 5 09:36:41 CEST 2021 x86_64 AMD Ryzen 5 3600 6-Core Processor AuthenticAMD GNU/Linux
  • Architecture: AMD64
  • QEMU flavor: qemu-hppa
  • QEMU version: 6.0.0, also with git 6.1.50 version
  • QEMU command line: qemu-hppa pow (the source provided)

Description of problem

The floating point power function produces incorrect values, and possibly stack misshapes as well.

Steps to reproduce

  1. $ hppa1.1-unknown-linux-gnu-gcc pow.c -o pow -lm -static
  2. $ qemu-hppa pow
  3. the expected result is 10.0 ^ 6.0 = 6000000.0, instead of 403.45

Additional information

Example C source to reproduce, pow.c:

#include <stdio.h>
#include <math.h>
int main()
{
    double base, expo, res;
    base=10.0;
    expo=6.0;
    // res sould be 1e+6
    res = pow(base, expo);
    printf("%.1lf^%.1lf = %.2lf\n", base, expo, res);
    return 0;
}
Edited by Barnabás Virágh