Bug 19406 - memchr description: may it access all @var{size} bytes?
Summary: memchr description: may it access all @var{size} bytes?
Status: NEW
Alias: None
Product: glibc
Classification: Unclassified
Component: manual (show other bugs)
Version: 2.22
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2015-12-27 15:41 UTC by Alexander Cherepanov
Modified: 2015-12-27 15:41 UTC (History)
2 users (show)

See Also:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Cherepanov 2015-12-27 15:41:29 UTC
The description of the memchr function in C11,, says that memchr cannot access the part of the array after the located char:

"The implementation shall behave as if it reads the characters sequentially and stops as soon as a matching character is found."

The glibc manual doesn't provide this guarantee:

"This function finds the first occurrence of the byte @var{c} (converted to an @code{unsigned char}) in the initial @var{size} bytes of the object beginning at @var{block}.  The return value is a pointer to the located byte, or a null pointer if no match was found."


The implementation is probably fine so only the manual is wrong.