public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
[parent not found: <bug-16794-25@http.gcc.gnu.org/bugzilla/>]
* [Bug c/16794] New: should warn about switched memset arguments
@ 2004-07-28  6:41 martin at v dot loewis dot de
  2004-08-14  7:27 ` [Bug c/16794] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 3+ messages in thread
From: martin at v dot loewis dot de @ 2004-07-28  6:41 UTC (permalink / raw)
  To: gcc-bugs

gcc should issue a warning for the code

#include <string.h>

int main(int argc, char*argv[])
{
        memset(argv[0], strlen(argv[0]), 0);
        return 0;
}

as passes a size_t for the "int c" argument, and 0 for the "size_t n" argument.
This is a common programmming mistake, as the order of arguments to memset is
counter-intuitive. Trigger for this warning could either be that the size_t
argument is in the wrong position, or that a size of 0 is passed, making the
function call have no effect. The warning should hint that possibly the argument
order should be switched.

-- 
           Summary: should warn about switched memset arguments
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: martin at v dot loewis dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i486-linux
  GCC host triplet: i486-linux
GCC target triplet: i486-linux


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


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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-16794-4@http.gcc.gnu.org/bugzilla/>
2023-03-31 11:42 ` [Bug c/16794] should warn about switched memset arguments pinskia at gcc dot gnu.org
     [not found] <bug-16794-25@http.gcc.gnu.org/bugzilla/>
2007-09-10 14:07 ` pinskia at gcc dot gnu dot org
2004-07-28  6:41 [Bug c/16794] New: " martin at v dot loewis dot de
2004-08-14  7:27 ` [Bug c/16794] " pinskia 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).