[Bug middle-end/94111] Wrong constant folding: decimal floating-point infinity casted to double -> zero

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Sep 17 14:24:37 GMT 2020


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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-8 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:8b53a85254e91903018498d70b59928b0d1dd9f9

commit r8-10460-g8b53a85254e91903018498d70b59928b0d1dd9f9
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Mar 11 09:33:52 2020 +0100

    dfp: Fix decimal_to_binary [PR94111]

    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.

    (cherry picked from commit 343c467ccdc24edb9acd7c60d54914d9656ab499)


More information about the Gcc-bugs mailing list