https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62181

--- Comment #16 from Xi Ruoyao <xry111 at mengyan1223 dot wang> ---
(In reply to Jonathan Wakely from comment #15)
> Was this question ever answered?
> https://gcc.gnu.org/ml/gcc-patches/2017-06/msg01337.html

Oh that's intentional.

This would make this warning more useful, while most people won't use a "char"
to address an array or something like.  For example, if someone has wrote a
string-like class but forgot to overload operator+=, this warning will detect
it when he writes "char c = getchar(); buggy_string t = s + c;".

And for something like

"char *p = s;  char x;  scanf("%hhd", &x);  p = p + x;"

1.  In C++ __INT8_TYPE__ is not __CHAR_TYPE__ so there will be no warning.  He
can use "int8_t x;" instead of "char x;".
2.  He can use p = &p[x], which is more clear and nobody will think this is an
append.

I remember I wrote a response, with an option to split this into
-Wstring-plus-int=1 and -Wstring-plus-int=2.  But why it wasn't sent?  I can't
remember.

Reply via email to