Hello, The std::regex constructor throws when passed "[b\\-a]". The message is "Invalid range in bracket expression.". I understand that this is a valid regular expression that specifies a character class consisting of a literal "b", a literal "-", and a literal "a". g++ version: 6.2.0. System: Ubuntu 12.04.2 LTS. Output of 'uname -a': Linux zeus 3.2.0-68-generic #102-Ubuntu SMP Tue Aug 12 22:02:15 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux gcc configuration options: ./configure --disable-multilib Build command line: g++ testRegex.cc -o testRegex -std=c++11 -Wall -Wextra -fno-strict-aliasing -fwrapv -fno-aggressive-loop-optimizations -fsanitize=undefined There are no compiler messages. This behaviour does not occur with gcc Ubuntu 4.9.2-0ubuntu1~14.04. This behaviour also occurs with MinGW-W64 5.3.0 and 6.1.0. Thank you, Alban
Created attachment 39543 [details] Test program with the bug Build the program: g++ testRegex.cc -o testRegex -std=c++11 Run: ./testRegex Output: Trying: [b\-a] Exception: Invalid range in bracket expression.
Created attachment 39544 [details] config.log from building gcc 6.2.0
Created attachment 39545 [details] Preprocessed file generated by -save-temps
\ is not special inside bracket expressions, [b\-a] means b and the range between \ and a. If you want to include a - in a bracket expression, put it first or last.
*** This bug has been marked as a duplicate of bug 77356 ***
(In reply to Andreas Schwab from comment #4) > \ is not special inside bracket expressions, [b\-a] means b and the range > between \ and a. If you want to include a - in a bracket expression, put it > first or last. That's true for POSIX BREs and EREs, but for ECMAScript escaping the dash should work (and does on trunk).