[Bug c/16794] New: should warn about switched memset arguments
martin at v dot loewis dot de
gcc-bugzilla@gcc.gnu.org
Wed Jul 28 06:41:00 GMT 2004
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
More information about the Gcc-bugs
mailing list