This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/61720] New: std::regex_search matches incorrectly
- From: "husky.puppy at mail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 05 Jul 2014 09:20:07 +0000
- Subject: [Bug libstdc++/61720] New: std::regex_search matches incorrectly
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61720
Bug ID: 61720
Summary: std::regex_search matches incorrectly
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: husky.puppy at mail dot com
Created attachment 33072
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33072&action=edit
Preprocessed sourcce code
When using std::regex_search to match the string R"("test\")" against the
regular expression R"("([^"]|\\")*[^\\]")", it incorrectly finds a match. The
std::regex_match on the other hand works as expected.
Source:
#include <regex>
#include <iostream>
int main()
{
std::string test = R"("test\")";
std::regex regex(R"("([^"]|\\")*[^\\]")");
std::smatch match;
std::regex_search(test, match, regex);
std::cout << "search: " << match.str() << std::endl;
std::regex_match(test, match, regex);
std::cout << "match: " << match.str() << std::endl;
return 0;
}
Output:
search: "test\"
match:
Command Line:
g++ -std=c++11 -Wall -Werror test.cpp
GCC Info:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.9.0-9'
--with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.9 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap
--disable-vtable-verify --enable-plugin --with-system-zlib
--disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --with-arch-32=i586 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.9.0 (Debian 4.9.0-9)
System Info:
Linux server 3.14-1-amd64 #1 SMP Debian 3.14.9-1 (2014-06-30) x86_64 GNU/Linux