[PATCH v1] Remove 'restrict' from 'nptr' in strtol(3)-like functions

Xi Ruoyao xry111@xry111.site
Sat Jul 6 02:24:16 GMT 2024


On Sat, 2024-07-06 at 00:02 +0200, Alejandro Colomar wrote:
> That's precisely the case with strtol(3): it doesn't access any objects
> through *endptr, and so that pointer need not be restrict.
> 
> Then, nptr is a read-only pointer, so is doesn't matter either if it's
> accessed or not.

Restrict allows to reorder any writes to other objects with an read from
nptr then. In strtol at least errno can be written, and depending on the
implementation of locale things there may be more.

TBAA does not help here because char aliases with anything.

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University


More information about the Gcc mailing list