Title
Problematic postconditions of regex_match and regex_search
Status
c++14
Section
[re.alg.match] [re.alg.search]
Submitter
Pete Becker

Created on 2012-10-24.00:00:00 last changed 123 months ago

Messages

Date: 2012-10-31.22:48:58

Proposed resolution:

This wording is relative to N3376.

  1. Change Table 142 as indicated:

    Table 142 — Effects of regex_match algorithm
    Element Value
    m[0].first first
    m[0].second last
    m[0].matched true if a full match was found.
    m[n].first For all integers 0 < n < m.size(), the start of the sequence that matched sub-expression n.
    Alternatively, if subexpression n did not participate in the match, then last.
    m[n].second For all integers 0 < n < m.size(), the end of the sequence that matched sub-expression n.
    Alternatively, if sub-expression n did not participate in the match, then last.
    m[n].matched For all integers 0 < n < m.size(), true if sub-expression n participated in the match, false otherwise.
  2. Change Table 143 as indicated:

    Table 143 — Effects of regex_search algorithm
    Element Value
    m[0].first The start of the sequence of characters that matched the regular expression
    m[0].second The end of the sequence of characters that matched the regular expression
    m[0].matched true if a match was found, and false otherwise.
    m[n].first For all integers 0 < n < m.size(), the start of the sequence that matched sub-expression n.
    Alternatively, if subexpression n did not participate in the match, then last.
    m[n].second For all integers 0 < n < m.size(), the end of the sequence that matched sub-expression n.
    Alternatively, if sub-expression n did not participate in the match, then last.
    m[n].matched For all integers 0 < n < m.size(), true if sub-expression n participated in the match, false otherwise.
Date: 2014-02-13.06:35:03

[ Issaquah 2014-02-11: Move to Immediate ]

Date: 2012-10-24.00:00:00

Table 142 lists post-conditions on the match_results object when a call to regex_match succeeds. regex_match is required to match the entire target sequence. The post-condition for m[0].matched is "true if a full match was found." Since these are conditions for a successful search which is, by definition, a full match, the post-condition should be simply "true".

There's an analogous probem in Table 143: the condition for m[0].matched is "true if a match was found, false otherwise." But Table 143 gives post-conditions for a successful match, so the condition should be simply "true".

Furthermore, they have explicit requirements for m[0].first, m[0].second, and m[0].matched. They also have requirements for the other elements of m, described as m[n].first, m[n].second, and m[n].matched, in each case qualifying the value of n as "for n < m.size()". Since there is an explicit description for n == 0, this qualification should be "for 0 < n < m.size()" in all 6 places.

History
Date User Action Args
2014-02-27 17:03:20adminsetstatus: wp -> c++14
2014-02-20 13:52:38adminsetstatus: immediate -> wp
2014-02-13 06:35:03adminsetstatus: new -> immediate
2012-10-31 22:48:58adminsetmessages: + msg6225
2012-10-31 22:48:58adminsetmessages: + msg6224
2012-10-24 00:00:00admincreate