Skip to content

Fix handling of escaped backslashes in expanded string (#464) #481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

filipsajdak
Copy link
Contributor

The original fix uses the std::copy_if algorithm with overlapping input and output ranges - that behavior is undefined.
After reviewing it with @Maiqel and @lukasz-matysiak, we have replaced it with the std::remove_if algorithm - which simplifies code and better describes what is happening, and does not exercise undefined behavior.

From https://en.cppreference.com/w/cpp/algorithm/copy:

The behavior is undefined if d_first is within the range [first, last)

All regression tests pass.

Original fix uses std::copy_if algorithm with overlapping input and output
ranges - that behaviour is undefined.
After reviewing it with @Maiqel and @lukasz-matysiak we have replace it
with std::remove_if algorithm - which better describe what is happening
and does not excercise undefined behaviour.

From https://en.cppreference.com/w/cpp/algorithm/copy:

> The behavior is undefined if d_first is within the range [first, last)
@hsutter hsutter merged commit 7078a5c into hsutter:main May 31, 2023
@filipsajdak filipsajdak deleted the fsajdak-fix-escaped-backslash-handling branch May 31, 2023 22:55
zaucy pushed a commit to zaucy/cppfront that referenced this pull request Dec 5, 2023
…sutter#481)

Original fix uses std::copy_if algorithm with overlapping input and output
ranges - that behaviour is undefined.
After reviewing it with @Maiqel and @lukasz-matysiak we have replace it
with std::remove_if algorithm - which better describe what is happening
and does not excercise undefined behaviour.

From https://en.cppreference.com/w/cpp/algorithm/copy:

> The behavior is undefined if d_first is within the range [first, last)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants