public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/42935]  New: Warning "u64 = u32 * u32;" - i.e. not casting one u32 to u64
@ 2010-02-02 10:10 etienne_lorrain at yahoo dot fr
  2010-02-24  0:17 ` [Bug c/42935] " manu at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: etienne_lorrain at yahoo dot fr @ 2010-02-02 10:10 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-06-07 18:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-02 10:10 [Bug c/42935] New: Warning "u64 = u32 * u32;" - i.e. not casting one u32 to u64 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
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

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).