[Bug c/59870] Gcc should warn conversion from "const char*" to "char*" for string literals
harald at gigawatt dot nl
gcc-bugzilla@gcc.gnu.org
Sat Jan 18 09:39:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59870
Harald van Dijk <harald at gigawatt dot nl> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |harald at gigawatt dot nl
--- Comment #2 from Harald van Dijk <harald at gigawatt dot nl> ---
The type of a string literal in C is char[N], unlike in C++ where it is const
char[N]. clang's -Weverything option enables -Wwrite-strings, which changes the
type const char[N] and because of that makes the compiler not conform to the C
standard. The same -Wwrite-strings option also exists in GCC already (in fact,
I would be surprised if clang's name for the option didn't come from GCC), so I
don't think there's anything in GCC that needs changing.
$ gcc -Wwrite-strings test.c
test.c: In function ‘main’:
test.c:4:19: warning: initialization discards ‘const’ qualifier from pointer
target type [enabled by default]
char* s = "test";
^
More information about the Gcc-bugs
mailing list