This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

### 3604. What is the effect of an invalid value of type `syntax_option_type`?

Section: 32.7.2 [re.regex.construct], 32.4.2 [re.synopt] Status: New Submitter: Jonathan Wakely Opened: 2021-09-27 Last modified: 2021-10-14

Priority: 3

View other active issues in [re.regex.construct].

View all other issues in [re.regex.construct].

View all issues with New status.

Discussion:

32.4.2 [re.synopt] says:

> A valid value of type `syntax_option_type` shall have at most one of the grammar elements `ECMAScript`, `basic`, `extended`, `awk`, `grep`, `egrep`, set.

But then we never say what happens if an invalid value is used.

What does `std::regex(".", std::regex::grep|std::regex::awk)` do? Is it undefined? Does it throw?

It seems reasonable for `basic_regex` constructors to throw if `f` is not a valid value, i.e. for each non-default constructor:

> Throws: `regex_error` if `f` is not a valid value, or if […] is not a valid regular expression according to the grammar specified by `f`.

However, there is no `regex_constants::error_code` value suitable for this error condition.

Also, the constructors say "Postconditions: `flags()` returns `f`." This prevents an implementation from storing `f|ECMAScript` in `flags()` if no grammar element is present in `f`. This seems like an unnecessary restriction, and forces implementations to do extra work to check if the `ECMAScript` grammar is in use. Arguably, it would even be better to require implementations to set `ECMAScript` in `flags()` if no grammar element was set in the flags passed to the constructor. This problem was introduced by LWG 2330.

[2021-10-14; Reflector poll]

Set priority to 3 after reflector poll.

Proposed resolution: