Opened 9 years ago

Closed 9 years ago

#9380 closed Bugs (worksforme)

regex return empty submatch on some machines/compilers

Reported by: Jannich Thorsen <jannich@…> Owned by: John Maddock
Milestone: To Be Determined Component: regex
Version: Boost 1.55.0 Severity: Problem
Keywords: Cc:

Description

Upgraded to 1.55.0 and now this regex fails on our 32bit Ubuntu, but still works fine on our 64bit Ubuntu and RedHat variants.

Configuration is: Ubuntu 8.04.4 LTS, 32bit, gcc 4.2.4

bool parseBusName(const std::string& busName) const {
    boost::regex regularExpressionBus ("^([^\[]+)\[([0-9]+)-([0-9]+)\]", boost::regex::extended);
    boost::cmatch w;
    if(!regex_match(busName.c_str(), w, regularExpressionBus))
      return false;

    std::cerr << w.size() << " >" << w[1] << "< >" << w[2] << "< >" << w[3] << "<" << std::endl;
    return true;
  }


parseBusName("top[0-1]")

output is: 4 >< >< ><
expected:  4 >top< >0< >1<

We where previously running boost 1.48.0 which worked fine on all our configurations.

NOTE: Replacing boost::regex::extended with boost::regex::perl makes the test pass again on 32bit/gcc4.2.4.

Thanks, Jannich

Change History (2)

comment:1 by John Maddock, 9 years ago

Actually that shouldn't work in any compiler/situation, you need

"^([^\\[]+)\\[([0-9]+)-([0-9]+)\\]"

as the regular expression if it really is embedded in code like that.

Then it works for me.

comment:2 by John Maddock, 9 years ago

Resolution: worksforme
Status: newclosed

Update: I've now had a chance to try this on Ubuntu (64-bit, but using -m32 to build 32-bit binaries) and it works fine for me.

Only thing I can think of is that you've somehow got the headers and/or binaries mismatched (ie different versions) on that machine?

Note: See TracTickets for help on using tickets.