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

--- Comment #10 from Iain Sandoe <iains at gcc dot gnu.org> ---
simplified C code reproduce (on 11.2 or 11.x up to r11-8936-gbe64e725111fdb9,
the following commit changes the optimisation of the loading and makes the bug
latent)

typedef int int32_t;

extern double floor( double );
extern double fabs( double );

static int32_t p10[] = {1, 10, 100, 1000, 10000};

int decimals(double n) {

    n = fabs(n);
    for (int ndigits=0; ndigits<=3; ndigits++) {
        double scaledN = n * p10[ndigits];
        if (scaledN == floor(scaledN)) {
            return ndigits;
        }
    }
    return 0;
}

Reply via email to