[Bug target/104117] gcc10 fails to build icu for ppc64 on 10.5.8 (direct access to a floating-point constant)
iains at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jan 19 15:01:22 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104117
--- Comment #2 from Iain Sandoe <iains at gcc dot gnu.org> ---
reduced testcase:
typedef int int32_t;
extern "C" {
extern double floor( double );
extern double fabs( double );
int atoi(const char *);
int sprintf(char * , const char * , ...) ;
}
namespace icu_67 {
class __attribute__((visibility("default"))) FixedDecimal {
public:
static int32_t decimals(double n);
};
//using namespace icu::pluralimpl;
//using icu::number::impl::DecimalQuantity;
static int32_t p10[] = {1, 10, 100, 1000, 10000};
int32_t FixedDecimal::decimals(double n) {
n = fabs(n);
for (int ndigits=0; ndigits<=3; ndigits++) {
double scaledN = n * p10[ndigits];
if (scaledN == floor(scaledN)) {
return ndigits;
}
}
char buf[30] = {0};
sprintf(buf, "%1.15e", n);
int exponent = atoi(buf+18);
int numFractionDigits = 15;
for (int i=16; ; --i) {
if (buf[i] != '0') {
break;
}
--numFractionDigits;
}
numFractionDigits -= exponent;
return numFractionDigits;
}
}
More information about the Gcc-bugs
mailing list