[RFC] Support for nonzero attribute

Miika nykseli@protonmail.com
Sat Jun 4 11:55:02 GMT 2022


On Saturday, June 4th, 2022 at 1:26 PM, Yair Lenga via Gcc <gcc@gcc.gnu.org> wrote:
> The specific non-zero constraint is a specific implementation of the range
> operator (with some exception see below). Wanted to suggest going for
> more ambitious goal: add min and max attributes to (integer) types and
> variables. This will address the specific case of non-zero, but has a lot
> of potential to be built upon: can be used for compile time testing, run
> time parameter checking, storage optimization (similar to packed), run time
> optimization (e.g. eliminating runtime tests), .... Also expected range
> information can have a positive impact on code safety/validation.


I like this idea a lot too. I'll definitely look into adding a "range"
variable attribute after the work with function attributes is done.
I'm not that familiar with GCC's optimizer but basic compiler warnings
should be fairly easy to implement.

Miika


More information about the Gcc mailing list