public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/94590] Incorrectly accepts invalid C++11 braced initialisation of double from long double if sizeof(long double)==sizeof(double) Date: Sun, 19 Apr 2020 17:32:23 +0000 [thread overview] Message-ID: <bug-94590-4-DGSXxDuZd8@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-94590-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94590 Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org --- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Untested fix: --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1008,10 +1008,17 @@ check_narrowing (tree type, tree init, tsubst_flags_t complain, || !int_fits_type_p (init, type))) ok = false; } + /* [dcl.init.list]#7.2: "from long double to double or float, or from + double to float". */ else if (TREE_CODE (ftype) == REAL_TYPE && TREE_CODE (type) == REAL_TYPE) { - if (TYPE_PRECISION (type) < TYPE_PRECISION (ftype)) + if ((same_type_p (ftype, long_double_type_node) + && (same_type_p (type, double_type_node) + || same_type_p (type, float_type_node))) + || (same_type_p (ftype, double_type_node) + && same_type_p (type, float_type_node)) + || (TYPE_PRECISION (type) < TYPE_PRECISION (ftype))) { if (TREE_CODE (init) == REAL_CST) {
next prev parent reply other threads:[~2020-04-19 17:32 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-14 8:59 [Bug c++/94590] New: " dangelog at gmail dot com 2020-04-14 10:15 ` [Bug c++/94590] " redi at gcc dot gnu.org 2020-04-15 8:42 ` dangelog at gmail dot com 2020-04-19 17:05 ` mpolacek at gcc dot gnu.org 2020-04-19 17:32 ` mpolacek at gcc dot gnu.org [this message] 2020-04-20 19:40 ` mpolacek at gcc dot gnu.org 2020-05-07 18:16 ` cvs-commit at gcc dot gnu.org 2020-05-07 18:18 ` mpolacek at gcc dot gnu.org 2020-05-07 23:35 ` dangelog at gmail dot com
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-94590-4-DGSXxDuZd8@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).