Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[unreachable.sentinel] Incorrect usage example of std::unreachable_sentinel #7859

Copy link
Copy link
Open
@xmcgcg

Description

@xmcgcg
Issue body actions

An incorrect description of an example was spotted on Stack Overflow (the comment under the question), [unreachable.sentinel] p2 says:

[Example 1 :

char* p;
// set p to point to a character buffer containing newlines
char* nl = find(p, unreachable_sentinel, '\n');

Provided a newline character really exists in the buffer, the use of unreachable_sentinel above potentially makes
the call to find more efficient since the loop test against the sentinel does not require a conditional branch. — end
example
]

The description says that the example is well-defined if a null character is reachable from p, but std::ranges::find requires the input range to be valid, as [iterator.requirements.general] p12 says:

The result of the application of library functions to invalid ranges is undefined.

Metadata

Metadata

Assignees

No one assigned

    Labels

    lwgIssue must be reviewed by LWG.Issue must be reviewed by LWG.not-editorialIssue is not deemed editorial; the editorial issue is kept open for tracking.Issue is not deemed editorial; the editorial issue is kept open for tracking.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.