On 5/10/20, Eric Gallager <eg...@gwmail.gwu.edu> wrote:
> On 1/10/20, Jason Merrill <ja...@redhat.com> wrote:
>> Back in 2009 Manuel sent a patch to avoid useless -Wconversion warnings
>> on compound assignment of types that get promoted to int:
>>
>> https://gcc.gnu.org/ml/gcc-patches/2009-08/msg00582.html
>>
>> Joseph argued that those warnings are sometimes useful, and that they
>> should be controlled by a separate flag.  So this patch introduces
>> -Warith-conversion, which is off by default in this patch.
>>
>> Joseph, is that default OK with you?  If not, can you explain your
>> reasoning more about why the warnings are desirable?  It seems to me
>> that even in cases where you don't know the ranges involved, it's wrong
>> for e.g. 'mychar += 1' to warn when 'myint += 1' doesn't.  In both
>> cases, the addition might overflow the range of the target type, but
>> that isn't about the conversion; the result is the same as if the
>> operation had been done in the operand/target type rather than the
>> promoted type.
>>
>> The change to cp/typeck.c is a placeholder to use if the default setting
>> changes; even if we end up warning by default for mychar = mychar + 1, I
>> really don't want to warn about mychar += 1.
>>
>> sign.diff is a prerequisite tidying that moves the warnings from
>> unsafe_conversion_p back into conversion_warning with the others.
>>
>> rshift.diff restores the short_shift code to the C++ front end so that C
>> and C++ give the same warnings with -Warith-conversion.
>>
>> Tested x86_64-pc-linux-gnu.  Comments?
>>
>
> Hi Jason, thanks for this new flag. Now that GCC 10 has been released
> I was checking the release notes to review everything new in GCC 10,
> and I didn't see any mention of -Warith-conversion on it. Could you
> add a quick note about -Warith-conversion to changes.html please?
>
> Thanks,
> Eric
>

Something just like "Some warnings that -Wconversion previously issued
now also require -Warith-conversion" or something would be fine.

Reply via email to