The semantic of `nosubs` should simply be that `let all parentheses not be a subexpression and do not capture it`.
Tested with -m64 and -m32 respectively. Thank you! -- Regards, Tim Shen
commit 6972b7eb795adb462182ec96684cc94b7bb8a338 Author: tim <timshe...@gmail.com> Date: Mon Jan 20 17:33:44 2014 -0500 2014-01-19 Tim Shen <timshe...@gmail.com> * include/bits/regex.tcc: Remove incorrect `nosubs` handling. * include/bits/regex_scanner.tcc: Handle `nosubs` correctly. * testsuite/28_regex/constants/syntax_option_type.cc: Add a test case. diff --git a/libstdc++-v3/include/bits/regex.tcc b/libstdc++-v3/include/bits/regex.tcc index 1ceac60..73f55df 100644 --- a/libstdc++-v3/include/bits/regex.tcc +++ b/libstdc++-v3/include/bits/regex.tcc @@ -126,8 +126,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __suf.second = __e; __suf.matched = (__suf.first != __suf.second); } - if (__re.flags() & regex_constants::nosubs) - __res.resize(3); } return __ret; } diff --git a/libstdc++-v3/include/bits/regex_scanner.tcc b/libstdc++-v3/include/bits/regex_scanner.tcc index d954d07..5332d2e 100644 --- a/libstdc++-v3/include/bits/regex_scanner.tcc +++ b/libstdc++-v3/include/bits/regex_scanner.tcc @@ -139,6 +139,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION else __throw_regex_error(regex_constants::error_paren); } + else if (_M_flags & regex_constants::nosubs) + _M_token = _S_token_subexpr_no_group_begin; else _M_token = _S_token_subexpr_begin; } diff --git a/libstdc++-v3/testsuite/28_regex/constants/syntax_option_type.cc b/libstdc++-v3/testsuite/28_regex/constants/syntax_option_type.cc index 22559f5..2423775 100644 --- a/libstdc++-v3/testsuite/28_regex/constants/syntax_option_type.cc +++ b/libstdc++-v3/testsuite/28_regex/constants/syntax_option_type.cc @@ -1,5 +1,4 @@ // { dg-options "-std=c++0x" } -// { dg-do compile } // // 2009-06-17 Stephen M. Webb <stephen.w...@xandros.com> // @@ -23,6 +22,7 @@ // 28.5.1 #include <regex> +#include <testsuite_hooks.h> void test01() @@ -82,10 +82,21 @@ test04_constexpr() constexpr auto a3 __attribute__((unused)) = ~grep; } +void +test05() +{ + using namespace std; + using namespace regex_constants; + regex re("((a)(s))", nosubs | ECMAScript); + VERIFY(re.mark_count() == 0); +} + int main() { test01(); test02(); test03(); + test04_constexpr(); + test05(); return 0; }