Title
What is the effect of an invalid value of type syntax_option_type?
Status
new
Section
[re.regex.construct][re.synopt]
Submitter
Jonathan Wakely

Created on 2021-09-27.00:00:00 last changed 1 month ago

Messages

Date: 2021-10-15.00:00:00

[ 2021-10-14; Reflector poll ]

Set priority to 3 after reflector poll.

Date: 2021-10-02.18:57:27

[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.

History
Date User Action Args
2021-10-14 11:35:36adminsetmessages: + msg12161
2021-09-27 00:00:00admincreate