public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "manu at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/42935] Warning "u64 = u32 * u32;" - i.e. not casting one u32 to u64 Date: Wed, 24 Feb 2010 10:23:00 -0000 [thread overview] Message-ID: <20100224102327.27609.qmail@sourceware.org> (raw) In-Reply-To: <bug-42935-1034@http.gcc.gnu.org/bugzilla/> ------- Comment #3 from manu at gcc dot gnu dot org 2010-02-24 10:23 ------- (In reply to comment #2) > It would be nice to have the warning in the second case too, i.e. for > (unsigned long long)(val1*val2). Actually, it is a bit weird that the operands are not promoted to unsigned long long. Normally, I would say that if you do an explicit cast, then we have to assume that you know what you are doing. However, in this case, the result is totally unexpected, so I think we could warn. Also for (double) (int * int) versus ((double) int * int). This is another subtle case. I think this is an interesting warning. > Another solution, probably a lot more complex to implement, is to have > a compilation switch to expand all calculus to 64 bits even when "int" > is 32 bits, and let the optimiser convert back to simpler assembly code > when the result used is only 32 bits. That is independent of this warning. If you want that, open a new PR and see what others say. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42935
next prev parent reply other threads:[~2010-02-24 10:23 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-02-02 10:10 [Bug c/42935] New: " etienne_lorrain at yahoo dot fr 2010-02-24 0:17 ` [Bug c/42935] " manu at gcc dot gnu dot org 2010-02-24 9:45 ` etienne_lorrain at yahoo dot fr 2010-02-24 10:23 ` manu at gcc dot gnu dot org [this message] 2010-06-07 17:52 ` [Bug c/42935] warn if a binary operation is performed on a type but the result is then casted to a larger type manu at gcc dot gnu dot org 2010-06-07 17:53 ` manu at gcc dot gnu dot org 2010-06-07 18:05 ` manu at gcc dot gnu dot 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=20100224102327.27609.qmail@sourceware.org \ --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).