Fix word boundary assertions under C++20 #345
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In C++20 with P1614R2 implemented, zero-width assertions
\b
and\B
do not work. For example, the following code fails with "Pattern can never match":This is caused by breaking change in
std::pair
comparison operators (after P1614R2std::pair
usesoperator<=>
). The spaceship operator prefers implicit conversion tobool
, if exists:https://godbolt.org/z/xnPreToW4
https://godbolt.org/z/T4cKEPrTf
So nearly all values of type
std::pair<ue2::graph_detail::vertex_descriptor, ue2::graph_detail::vertex_descriptor>
compare equal: https://github.com/intel/hyperscan/blob/master/src/util/ue2_graph.h#L179-L188, soedge_cache_t
is malformed: https://github.com/intel/hyperscan/blob/master/src/compiler/asserts.cpp#L284-L288, and the NFA graph after removeAssertVertices becomes disconnected.The fix is simple: just mark
operator bool()
asexplicit
.