http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59870
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Chengnian Sun from comment #6) > (In reply to Harald van Dijk from comment #2) > > 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"; > > ^ > > > > Yes, this option works. > > However, one more question. Does "[enabled by default]" imply that this type > of warnings is enabled by default? If yes, then it is inconsistent with the > current setting of GCC flags (i.e., this flag should be explicitly enabled). Please re-read comment #2. -Wwrite-strings changes the type of string literals to be const char[] rather than char[] as what the standard points out it should be. The warning that is enabled by default is the one which warns about discarding const qualifier.