Why don\'t ANSI C compilers flag the use of a string literal argument in a function call in which the correponding parameter does not have a const qualifier? For example,
The GNU compiler (and the Intel C compiler as well, iirc) will emit a warning, if -Wwrite-string
is used:
$ gcc -Wall -Wwrite-strings -o foo /tmp/foo.c
/tmp/foo.c: In function 'main':
/tmp/foo.c:12: warning: passing argument 1 of 'somefunc' discards qualifiers from pointer target type
/tmp/foo.c:3: note: expected 'char *' but argument is of type 'const char *'
Concerning VS2010, I can't help you.