Open stevemk14ebr opened 4 years ago
I debugged this some more, the issue appears to be capture groups inside of non-capturing groups. When re-written with the equivalent expression, the results are as expected:
([a-zA-Z_][a-zA-Z0-9_*]*)\\s*([a-zA-Z_][a-zA-Z0-9_*]*\\s*)?(?:[a-zA-Z_][a-zA-Z0-9_]*)?\\s*\\((.*)\\)
This confirms incorrect behavior I believe. When testing with any other regex engine the first variant captures correctl.
Reduced test case; I was able to eliminate the non-capture groups:
C:\Temp>type meow.cpp
#include <iostream>
#include <regex>
#include <string>
using namespace std;
int main() {
const regex r{R"((A+)\s*(B+)?\s*B*)"};
smatch m;
const string s{"AAA BBB"};
if (regex_match(s, m, r)) {
cout << "This should be \"AAA\": \"" << m[1] << "\"\n";
cout << "This should be \"BBB\": \"" << m[2] << "\"\n";
}
}
C:\Temp>cl /EHsc /nologo /W4 meow.cpp
meow.cpp
C:\Temp>meow
This should be "AAA": "AAA"
This should be "BBB": ""
Describe the bug In the following code snippet, the second regex capture called callConv fails to be captured. Instead the group is set to 'false'. This behavior does not occur on clang or GCC.
for convenience, the unespaced regex is as follows. It regexs the return value, optional calling convention, and then parameters all as one with optional *'s on the type names.
Expected behavior The expected output would be that the second capture group contains the string 'stdcall' as in the online compiler here: https://onlinegdb.com/ry28UXodI
STL version