https://github.com/AaronBallman commented:

Thank you for working on this! There's a few things worth thinking about here:

Based on past experience, we don't generally accept new off-by-default 
diagnostics unless there's a very strong signal that users will enable them 
(most off-by-default diagnostics are not enabled very often which makes adding 
and maintaining them questionable). Instead, we ask what can be done to enable 
it by default which generally means a near-zero false positive rate. I don't 
believe this diagnostic would meet the bar for it being off-by-default.

"False positive" is hard to nail down here given that it's well-defined 
behavior. Limiting it to just multiplication and addition seems questionable to 
me. e.g., why shouldn't `0u - 1u` be diagnosed? If diagnosing that, why not 
`-1u`?

My intuition is that this kind of diagnostic is better left to other tooling 
(overflow behavior types, sanitizers, linters or static analyzers) given that 
it's well-defined behavior both at runtime and constexpr evaluation time and 
how much code intentionally overflows even constant expressions. However, I 
think @ojhunt has been thinking about this design space a considerable amount 
and maybe he has a different take on this.

https://github.com/llvm/llvm-project/pull/222173
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to