On Mon, May 15, 2017 at 3:58 PM, Martin Sebor <mse...@gmail.com> wrote:
>> So how about the following then? I stayed with the catch part and added
>> a parameter to the warning to let the user decide on the warnings she/he
>> wants to get: -Wcatch-value=n.
>> -Wcatch-value=1 only warns for polymorphic classes that are caught by
>> value (to avoid slicing), -Wcatch-value=2 warns for all classes that
>> are caught by value (to avoid copies). And finally -Wcatch-value=3
>> warns for everything not caught by reference to find typos (like pointer
>> instead of reference) and bad coding practices.
>
> It seems reasonable to me.  I'm not too fond of multi-level
> warnings since few users take advantage of anything but the
> default, but this case is simple and innocuous enough that
> I don't think it can do harm.

>> Bootstrapped and regtested on x86_64-pc-linux-gnu.
>> OK for trunk?

OK.

>> If so, would it make sense to add -Wcatch-value=1 to -Wextra or even -Wall?
>> I would do this in a seperate patch, becuase I haven't checked what that
>> would mean for the testsuite.
>
> I can't think of a use case for polymorphic slicing that's not
> harmful so unless there is a common one that escapes me, I'd say
> -Wall.

Agreed.  But then you'll probably want to allow -Wno-catch-value to turn it off.

Jason

Reply via email to