File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11void foo (char *str) {}
22
33int main () {
4- // warning: ISO C++11 does not allow conversion from string literal to 'char *' [ -Wwritable-strings]
4+ // -Wwritable-strings warning triggered
55 char *mutable_strings[] = {" a" , " b" , " c" };
66 const char *immutable_strings[] = {" a" , " b" , " c" };
77
@@ -10,6 +10,6 @@ int main() {
1010
1111 foo (" world" );
1212 foo (mutable_string);
13- // This is not allowed, only string literals to char* are allowed: foo(immutable_string);
13+ // Calling foo with immutable_string is an error, not an warning
1414 return 0 ;
1515}
Original file line number Diff line number Diff line change 11void foo (char * str ) {}
22
33int main () {
4- // warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
54 char * mutable_strings [] = {"a" , "b" , "c" };
65 const char * immutable_strings [] = {"a" , "b" , "c" };
76
@@ -10,6 +9,6 @@ int main() {
109
1110 foo ("world" );
1211 foo (mutable_string );
13- // This is not allowed, only string literals to char* are allowed: foo(immutable_string);
12+ // Calling foo with immutable_string is an error
1413 return 0 ;
1514}
You can’t perform that action at this time.
0 commit comments