Bug 67403 - std::regex is not matching
Summary: std::regex is not matching
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.8.4
: P3 normal
Target Milestone: 4.9.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-30 23:22 UTC by Ryan Gonzalez
Modified: 2015-09-01 14:47 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan Gonzalez 2015-08-30 23:22:27 UTC
Reproducing it is simple:

#include <iostream>
#include <string>
#include <regex>

using namespace std;

int main() {
    cout << regex_search(string{"int"}, regex{"int"}) << '\n';
    return 0;
}

This *should* print 1, and with libc++ it does. GCC? It prints 0. This had me practically tearing my hair out trying to figure out what was wrong with my regexes! :/

I searched for existing bugs related to this, but couldn't find any. I'm sorry if this is a duplicate...
Comment 1 Andrew Pinski 2015-08-30 23:31:42 UTC
Iirc regex was not implemented in 4.8.x. Try 4.9 and above.
Comment 2 Ryan Gonzalez 2015-08-31 15:38:00 UTC
(In reply to Andrew Pinski from comment #1)
> Iirc regex was not implemented in 4.8.x. Try 4.9 and above.

...but then why are the functions present? I would've preferred a compile-time error if that is the case.
Comment 3 Mikhail Maltsev 2015-08-31 17:59:44 UTC
Here is rather detailed explanation from Jonathan Wakely (he is the maintainer of libstdc++):
https://stackoverflow.com/questions/12530406/is-gcc-4-7-and-gcc-4-8-buggy-about-regular-expressions/12665408
Comment 4 Jonathan Wakely 2015-09-01 14:47:22 UTC
Apart from that 4.8 is not supported anyway, so reporting bugs against it won't achieve anything except being asked to try a current, supported release. If you do that you will find it works in 4.9 and later.