mesa icon indicating copy to clipboard operation
mesa copied to clipboard

Add checks for uninitialized integers?

Open rjfarmer opened this issue 4 years ago • 2 comments

Something I found while fixing thinags in 13837 is that we don't currently have anyway to set integer arrays (and I presume scaler ints) to an invalid value to check for uninitialized values. For floats we can set things to a nan. Maybe we should expand the set_nan code to set int arrays to -huge(int) as an invalid value? We won't get the nice crash on use we get with a nan but at least it will be easier to see when we haven't set an array properly.

rjfarmer avatar May 31 '20 20:05 rjfarmer

I think using -huge(int) is a good plan. We could also add an is_bad interface that supports integers and just checks for the -huge(int) value.

-Adam On May 31, 2020, 4:37 PM -0400, Robert Farmer [email protected], wrote:

Something I found while fixing thinags in 13837 is that we don't currently have anyway to set integer arrays (and I presume scaler ints) to an invalid value to check for uninitialized values. For floats we can set things to a nan. Maybe we should expand the set_nan code to set int arrays to -huge(int) as an invalid value? We won't get the nice crash on use we get with a nan but at least it will be easier to see when we haven't set an array properly. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

adamjermyn avatar Jun 01 '20 14:06 adamjermyn

If we do this I suggest we don't call it set_nan and instead call it set_bad. Then it's clearer that we're setting bad values (which means NaN for reals but -huge(int) for ints).

adamjermyn avatar Jan 12 '21 16:01 adamjermyn