public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/24542]  New: integer overflow should be warned on assignment to wider variable
@ 2005-10-26 14:54 alexey at hyperroll dot com
  2005-10-26 15:01 ` [Bug c/24542] " alexey at hyperroll dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 13+ messages in thread
From: alexey at hyperroll dot com @ 2005-10-26 14:54 UTC (permalink / raw)
  To: gcc-bugs

The following code is ISO and ANSI standard compliant:
   unsigned x1, x2;
   unsigned long long y1;
   ... /* here we assign to x1 and x2 */
   y1 = x1 * x2; /* no castings -- silent overflow may occur on assignment */
   ...
   {
      unsigned long long y2 = x1 * x2; /* no castings -- silent overflow may
occur on initialization */
      ...
   }

(Instead of multiplication, addition or left shift shold be dealt with, too.)

When the binary operation result is assigned to lvalue of the same width, it's
OK not to warn about probable overflow. But in these cases, "do what I mean" is
obvious.


-- 
           Summary: integer overflow should be warned on assignment to wider
                    variable
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: alexey at hyperroll dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24542


^ permalink raw reply	[flat|nested] 13+ messages in thread
[parent not found: <bug-24542-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2023-03-31  8:15 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-26 14:54 [Bug c/24542] New: integer overflow should be warned on assignment to wider variable alexey at hyperroll dot com
2005-10-26 15:01 ` [Bug c/24542] " alexey at hyperroll dot com
2005-10-26 15:03 ` alexey at hyperroll dot com
2005-10-26 15:59 ` [Bug c/24542] potential " pinskia at gcc dot gnu dot org
2005-10-26 16:00 ` pinskia at gcc dot gnu dot org
2005-10-26 17:12 ` alexey at hyperroll dot com
2005-11-01 22:29 ` pinskia at gcc dot gnu dot org
2006-03-13 21:49 ` alexey at hyperroll dot com
2006-03-13 21:52 ` pinskia at gcc dot gnu dot org
2006-09-18  0:18 ` pinskia at gcc dot gnu dot org
2006-09-18  5:48 ` alexey at hyperroll dot com
     [not found] <bug-24542-4@http.gcc.gnu.org/bugzilla/>
2023-03-31  7:16 ` pinskia at gcc dot gnu.org
2023-03-31  8:15 ` zhangboyang.id at gmail dot com

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