public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "etienne_lorrain at yahoo dot fr" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/42935] New: Warning "u64 = u32 * u32;" - i.e. not casting one u32 to u64 Date: Tue, 02 Feb 2010 10:10:00 -0000 [thread overview] Message-ID: <bug-42935-1034@http.gcc.gnu.org/bugzilla/> (raw) It is a beginer bug, but it would be nice to get a warning in: #include <stdio.h> unsigned val1 = 0x10000000, val2 = 0x100; int main(int argc, char **argv) { unsigned long long val3 = val1 * val2; printf ("val1 = 0x%X, val2 = 0x%X, val3 = 0x%llX, val1*val2 = 0x%llX\n", val1, val2, val3, (unsigned long long)(val1*val2)); } Obviously the line printed is: val1 = 0x10000000, val2 = 0x100, val3 = 0x0, val1*val2 = 0x0 (compiled with "gcc -w -Wall -O2 tmp.c" you get no warning) Got bitten yesterday by gcc-4.4.3, reproduced today on gcc version 4.1.2. -- Summary: Warning "u64 = u32 * u32;" - i.e. not casting one u32 to u64 Product: gcc Version: 4.4.3 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: etienne_lorrain at yahoo dot fr GCC build triplet: i686-pc-cygwin GCC host triplet: i686-pc-cygwin GCC target triplet: i686-pc-cygwin http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42935
next reply other threads:[~2010-02-02 10:10 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-02-02 10:10 etienne_lorrain at yahoo dot fr [this message] 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 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=bug-42935-1034@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).