Ticket #3586 (closed Bugs: fixed)

Opened 8 years ago

Last modified 8 years ago

Use of Greedy quantifiers in Quoted Expressions locks up at regex compile

Reported by: nmaximillian@… Owned by: eric_niebler
Milestone: To Be Determined Component: xpressive
Version: Boost 1.38.0 Severity: Problem
Keywords: Cc:


The following will not compile: \Q.*\E and causes the program to lockup at the compile step. I have attempted other usages: '\Qh*\E', '\Q.+\E', '\Q+\E', '\Q*\E' etc. and they all lock-up on compile. Note that escaping the quantifier will allow it to compile (but it is a different expression): '\Q.\*\E' -- compiles but will only match '.\*' not '.*'

#include <iostream>
#include <boost/xpressive/xpressive.hpp>

using namespace boost::xpressive;

int main()
    std::string hello( "hello .* world!" );

    std::cout << "compile regex" << std::endl;
    sregex rex = sregex::compile( "\\Q.*\\E" );
    smatch what;
    std::cout << "Get Iterator" << std::endl;
    sregex_iterator cur( hello.begin(), hello.end(), rex );
    sregex_iterator end;

    std::cout << "begin search" << std::endl;
    while( cur != end ) {
        smatch const &what = *cur;
        std::cout << "found: " << what[0] << '\n'; 

    return 0;


Change History

comment:1 Changed 8 years ago by eric_niebler

  • Status changed from new to closed
  • Resolution set to fixed

(In [57346]) fix infinite loop with some uses of \Q...\E quotemeta, fixes #3586


Add a comment

Modify Ticket

Change Properties
<Author field>
as closed
The resolution will be deleted. Next status will be 'reopened'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.