Sunday, 15 April 2012

c - Aliased arguments in strtol -



c - Aliased arguments in strtol -

here how strtol has declared according § 7.22.1.4 c11 (n1570):

#include <stdlib.h> long int strtol (const char *restrict nptr, char **restrict endptr, int base);

as far know, restrict keyword means object referenced lvalue *nptr accessed or value straight derived it.

however, lot of programmers, , experienced ones, utilize strtol in next way:

#include <stdlib.h> strtol (p, &p, 10);

in case, **endptr == **&p == *p == *nptr, , behavior undefined. right?

no. nil accessed via **endptr in strtol. *endptr, separate object, accessed.

c restrict-qualifier strtol

No comments:

Post a Comment