Regex_iterator causes infinite loop

Tim Shen timshen91@gmail.com
Wed Sep 4 02:27:00 GMT 2013


On Tue, Sep 3, 2013 at 4:57 PM, Stefan Schweter <stefan@schweter.it> wrote:
> Hi,
>
> I tested the following code with gcc 4.9 (trunk: 20130903) + the
> "Rewrite _stateSeq patch" applied:
>
> #include <iostream>
> #include <regex>
>
> int main()
> {
>         std::setlocale(LC_ALL, "");
>
>         std::wstring str2 = L"ä\u2009Ä\u2009ö\u2009Ö\u2009ü\u2009Ü";
>
>         std::wregex re2;
>         re2.imbue(std::locale(""));
>
>         re2.assign(L"([[:lower:]]{0,1}[[:space:]]{0,1}[[:upper:]]{0,1})");
>
>         for (std::wsregex_iterator p(str2.begin(), str2.end(), re2);
>              p != std::wsregex_iterator{}; ++p) {
>                 std::wcout << (*p)[1] << std::endl;
>         }
>
>         return 0;
> }
>
> Unfortunately, this causes an infinite loop. The last
> "{0,1}" should be the problem in that context.
>
> Thanks,
>
> Stefan

This is because regex_constants::match_not_null,
regex_constants::match_continuous and
regex_constants::match_prev_avail are not implemented yet.

It shall be fixed after completing assertion. I'll post a testcase later.


-- 
Tim Shen



More information about the Libstdc++ mailing list