microsoft / microsoft/STL

`<regex>`: `regex_traits<_Elem>` uses an inadmissible value of type `char_class_type` to represent character class "w"

Open
#5,242 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug regex vNext
Dominant language
C++
Stars
11.1k
Forks
1.7k
Avg merge
4d 15h
Merged PRs (30d)
22

Description

regex_traits<_Elem> uses static_cast<ctype_base::mask>(-1) to represent the character class "w":

https://github.com/microsoft/STL/blob/8124540f8bce3faad76a6dddd050f9a69af4b87d/stl/inc/regex#L354

This is an inadmissible choice, because it violates [re.grammar]/9:

The results from multiple calls to traits_inst.lookup_classname can be bitwise or'ed together and subsequently passed to traits_inst.isctype.

Specifically, or'ing the char_class_type for "w" with the char_class_type for any other character class always produces the value for "w" again, even if the combination should match more characters.

Additional remarks

I think resolving this issue will break ABI. However, it should be possible to mitigate the problems caused by this issue.

vNext note: Resolving this issue will require breaking binary compatibility. We won't be able to accept pull requests for this issue until the vNext branch is available. See #169 for more information.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with stl/inc/regex around the referenced regex_traits<_Elem> implementation and read [re.grammar]/9. Determine how character-class values should combine without violating the ABI, with the vNext branch and #169 as context; done means combined class lookups produce the required matches and compatibility concerns are addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.