2 ms·
> Do not look outside the bounds of the object you are given. Do not even try to look; computing a pointer that points outside the object it was created from i
by saagarjha 6y ago
> Do not look outside the bounds of the object you are given.
Do not even try to look; computing a pointer that points outside the object it was created from is undefined.
- sanxiyn 6y agoYes in current C standard. As far as I know this is not necessary for optimizations and I want this to be fixed in the future C standard.
- saagarjha 6y agoI'm not very sure this is a good idea–what exactly is the benefit of allowing the creation of off-by-one pointers that you can't do anything with?
- sanxiyn 6y agoMy motivation is to prevent accidental UB. Let p be array of length 10. Currently, p + 15 - 10 is UB so you must parenthesize p + (15 - 10). This seems preventable and unnecessary.