public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/103031] [12 Regression] Missing static initializer folding with -frounding-math Date: Wed, 03 Nov 2021 15:00:02 +0000 [thread overview] Message-ID: <bug-103031-4-dNfGhvKTxY@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-103031-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103031 --- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Joseph Myers <jsm28@gcc.gnu.org>: https://gcc.gnu.org/g:600dcd74b8e614c996b492d97878660faf484094 commit r12-4872-g600dcd74b8e614c996b492d97878660faf484094 Author: Joseph Myers <joseph@codesourcery.com> Date: Wed Nov 3 14:58:25 2021 +0000 c: Fold implicit integer-to-floating conversions in static initializers with -frounding-math [PR103031] Recent fixes to avoid inappropriate folding of some conversions to floating-point types with -frounding-math also prevented such folding in C static initializers, when folding (in the default rounding mode, exceptions discarded) is required for correctness. Folding for static initializers is handled via functions in fold-const.c calling START_FOLD_INIT and END_FOLD_INIT to adjust flags such as flag_rounding_math that should not apply in static initializer context, but no such function was being called for the folding of these implicit conversions to the type of the object being initialized, only for explicit conversions as part of the initializer. Arrange for relevant folding (a fold call in convert, in particular) to use this special initializer handling (via a new fold_init function, in particular). Because convert is used by language-independent code but defined in each front end, this isn't as simple as just adding a new default argument to it. Instead, I added a new convert_init function; that then gets called by c-family code, and C and C++ need convert_init implementations (the C++ one does nothing different from convert and will never actually get called because the new convert_and_check argument will never be true from C++), but other languages don't. Bootstrapped with no regressions for x86_64-pc-linux-gnu. gcc/ PR c/103031 * fold-const.c (fold_init): New function. * fold-const.h (fold_init): New prototype. gcc/c-family/ PR c/103031 * c-common.c (convert_and_check): Add argument init_const. Call convert_init if init_const. * c-common.h (convert_and_check): Update prototype. (convert_init): New prototype. gcc/c/ PR c/103031 * c-convert.c (c_convert): New function, based on convert. (convert): Make into wrapper of c_convert. (convert_init): New function. * c-typeck.c (enum impl_conv): Add ic_init_const. (convert_for_assignment): Handle ic_init_const like ic_init. Add new argument to convert_and_check call. (digest_init): Pass ic_init_const to convert_for_assignment for initializers required to be constant. gcc/cp/ PR c/103031 * cvt.c (convert_init): New function. gcc/testsuite/ PR c/103031 * gcc.dg/init-rounding-math-1.c: New test.
next prev parent reply other threads:[~2021-11-03 15:00 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-11-01 20:44 [Bug middle-end/103031] New: " jsm28 at gcc dot gnu.org 2021-11-01 20:47 ` [Bug middle-end/103031] " pinskia at gcc dot gnu.org 2021-11-02 7:43 ` [Bug c/103031] " rguenth at gcc dot gnu.org 2021-11-03 15:00 ` cvs-commit at gcc dot gnu.org [this message] 2021-11-03 15:01 ` jsm28 at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-103031-4-dNfGhvKTxY@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).