This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/16794] New: should warn about switched memset arguments
- From: "martin at v dot loewis dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Jul 2004 06:41:49 -0000
- Subject: [Bug c/16794] New: should warn about switched memset arguments
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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