As e.g. decimal_from_decnumber shows, the REAL_VALUE_TYPE representation
contains a decimal128 embedded in ->sig only if it is rvc_normal, for
other kinds like rvc_inf or rvc_nan, ->sig is ignored and everything is
contained in the REAL_VALUE_TYPE flags (cl, sign, signalling and decimal).
decimal_to_binary which is used when folding a decimal{32,64,128} constant
to a binary floating point type ignores this and thus folds infinities and
NaNs into +0.0.
The following patch fixes that by only doing that for rvc_normal.
Similarly to the binary to decimal folding, it goes through a string, in
order to e.g. deal with canonical NaN mantissas, or binary float formats
that don't support infinities and/or NaNs.
2020-03-11 Jakub Jelinek <jakub@redhat.com>
PR middle-end/94111
* dfp.c (decimal_to_binary): Only use decimal128ToString if from->cl
is rvc_normal, otherwise use real_to_decimal to print the number to
string.
* gcc.dg/dfp/pr94111.c: New test.
| Name |
Last commit
|
Last update |
|---|---|---|
| .. | ||
| Wbad-function-cast-1.c | Loading commit data... | |
| Wtraditional-conversion-2.c | Loading commit data... | |
| altivec-types.c | Loading commit data... | |
| bid-non-canonical-d128-1.c | Loading commit data... | |
| bid-non-canonical-d128-2.c | Loading commit data... | |
| bid-non-canonical-d128-3.c | Loading commit data... | |
| bid-non-canonical-d128-4.c | Loading commit data... | |
| bid-non-canonical-d32-1.c | Loading commit data... | |
| bid-non-canonical-d32-2.c | Loading commit data... | |
| bid-non-canonical-d64-1.c | Loading commit data... | |
| bid-non-canonical-d64-2.c | Loading commit data... | |
| builtin-complex.c | Loading commit data... | |
| builtin-tgmath-dfp-err.c | Loading commit data... | |
| builtin-tgmath-dfp.c | Loading commit data... | |
| c11-constants-1.c | Loading commit data... | |
| c11-constants-2.c | Loading commit data... | |
| c11-keywords-1.c | Loading commit data... | |
| c11-keywords-2.c | Loading commit data... | |
| c2x-builtins-dfp-1.c | Loading commit data... | |
| c2x-constants-1.c | Loading commit data... | |
| c2x-constants-2.c | Loading commit data... | |
| c2x-float-dfp-1.c | Loading commit data... | |
| c2x-float-dfp-2.c | Loading commit data... | |
| c2x-float-dfp-3.c | Loading commit data... | |
| c2x-keywords-1.c | Loading commit data... | |
| c2x-keywords-2.c | Loading commit data... | |
| cast-bad.c | Loading commit data... | |
| composite-type.c | Loading commit data... | |
| constants-c99.c | Loading commit data... | |
| constants-hex.c | Loading commit data... | |
| constants-pedantic.c | Loading commit data... | |
| constants.c | Loading commit data... | |
| convert-complex.c | Loading commit data... | |
| convert-dfp-round-thread.c | Loading commit data... | |
| convert-dfp-round.c | Loading commit data... | |
| ctypes.c | Loading commit data... | |
| ddmode-ice.c | Loading commit data... | |
| dec-eval-method-2.c | Loading commit data... | |
| dec-eval-method.c | Loading commit data... | |
| decfloat-constants.c | Loading commit data... | |
| dfp-dbg.h | Loading commit data... | |
| dfp-except.h | Loading commit data... | |
| dfp-round.h | Loading commit data... | |
| dfp.exp | Loading commit data... | |
| fe-binop.c | Loading commit data... | |
| fe-check.h | Loading commit data... | |
| fe-convert-1.c | Loading commit data... | |
| fe-convert-2.c | Loading commit data... | |
| fe-convert-3.c | Loading commit data... | |
| float-constant-double.c | Loading commit data... | |
| floatn.c | Loading commit data... | |
| keywords-c89.c | Loading commit data... | |
| keywords-c99.c | Loading commit data... | |
| keywords-pedantic.c | Loading commit data... | |
| keywords-reserved.c | Loading commit data... | |
| operator-bitwise.c | Loading commit data... | |
| pr31344.c | Loading commit data... | |
| pr37435.c | Loading commit data... | |
| pr41049.c | Loading commit data... | |
| pr48204.c | Loading commit data... | |
| pr48928.c | Loading commit data... | |
| pr52140.c | Loading commit data... | |
| pr70052.c | Loading commit data... | |
| pr79487.c | Loading commit data... | |
| pr79515.c | Loading commit data... | |
| pr94111.c | Loading commit data... | |
| pragma-float-const-decimal64-1.c | Loading commit data... | |
| pragma-float-const-decimal64-2.c | Loading commit data... | |
| pragma-float-const-decimal64-3.c | Loading commit data... | |
| pragma-float-const-decimal64-4.c | Loading commit data... | |
| pragma-float-const-decimal64-5.c | Loading commit data... | |
| pragma-float-const-decimal64-6.c | Loading commit data... | |
| pragma-float-const-decimal64-7.c | Loading commit data... | |
| pragma-float-const-decimal64-8.c | Loading commit data... | |
| struct-union.c | Loading commit data... | |
| tr24732-float-dfp-1.c | Loading commit data... | |
| ts18661-2-float-dfp-1.c | Loading commit data... | |
| typespec.c | Loading commit data... | |
| union-init.c | Loading commit data... | |
| usual-arith-conv-bad-2.c | Loading commit data... | |
| usual-arith-conv-bad-3.c | Loading commit data... | |
| usual-arith-conv-bad.c | Loading commit data... | |
| warn-abs-2.c | Loading commit data... | |
| wtr-conversion-1.c | Loading commit data... |