https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39878
--- Comment #2 from Fred J. Tydeman <tydeman at tybor dot com> ---
With gcc 15.1.1, the same problem still exists.
/*
* Compiler converts some decimal FP constants wrong.
CFLAGS="-H -std=gnu23 -O0 -march=native -mhard-float -mfpmath=387 -mieee-fp \
-enable-decimal-float=yes \
-fexcess-precision=standard \
-ffloat-store \
-ffp-contract=off \
-fmath-errno \
-fno-associative-math \
-fno-builtin \
-fno-cx-limited-range \
-fno-fast-math \
-fno-finite-math-only \
-fno-reciprocal-math \
-fno-unsafe-math-optimizations \
-frounding-math \
-fsignaling-nans \
-fsigned-zeros \
-ftrapping-math \
${INCS} \
-I/usr/include/dfp"
*/
#define __STDC_WANT_DEC_FP__
#include <assert.h>
int main(void){
{
_Decimal32 fp32 =
+5.0000000000000000000000000000000000000000000000000000001e-102DF;
assert(fp32 == +1.0000000e-101DF);
}
{
_Decimal32 fp32 =
+.000000000000000000000099999949999999999999999999999999999e-73DF;
assert(fp32 == +9.9999900e-96DF);
}
{
_Decimal32 fp32 =
+09999998.50000000000000000000000000000000000000000000000000001DF;
assert(fp32 == +9.9999990e+06DF);
}
{
_Decimal32 fp32 =
+09999999.49999999999999999999999999999999999999999999999999999DF;
assert(fp32 == +9.9999990e+06DF);
}
{
_Decimal32 fp32 =
+10000005.00000000000000000000000000000000000000000000000000001DF;
assert(fp32 == +1000001.DF);
}
{
_Decimal32 fp32 =
+10000014.99999999999999999999999999999999999999999999999999999DF;
assert(fp32 == +1000001.DF);
}
{
_Decimal32 fp32 =
+9999999499999999999999999999.999999799999999999999999999999e69DF;
assert(fp32 == +9.9999990e+96DF);
}
{
_Decimal64 fp64 =
+5.0000000000000000000000000000000000000000000000000000001e-399DD;
assert(fp64 == +1.0000000000000000e-398DD);
}
{
_Decimal64 fp64 =
+.00000000000000000000099999999999999949999999999999999999e-362DD;
assert(fp64 == +9.9999999999999900e-384DD);
}
{
_Decimal64 fp64 =
+09999999999999998.50000000000000000000000000000000000000000001DD;
assert(fp64 == +9.9999999999999990e+15DD);
}
{
_Decimal64 fp64 =
+09999999999999999.49999999999999999999999999999999999999999999DD;
assert(fp64 == +9.9999999999999990e+15DD);
}
{
_Decimal64 fp64 =
+10000000000000005.00000000000000000000000000000000000000000001DD;
assert(fp64 == +1.0000000000000010e+16DD);
}
{
_Decimal64 fp64 =
+9999999999999999499999999999.99999999999999999999999999999e357DD;
assert(fp64 == +9.9999999999999990e+384DD);
}
return 0;
}