The standard says that it is invalid for more than one grammar element to be set in a value of type regex_constants::syntax_option_type. This adds a check in the regex compiler andthrows an exception if an invalid value is used. Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: * include/bits/regex_compiler.h (_Compiler::_S_validate): New function. * include/bits/regex_compiler.tcc (_Compiler::_Compiler): Use _S_validate to check flags. * include/bits/regex_error.h (_S_grammar): New error code for internal use. * testsuite/28_regex/basic_regex/ctors/grammar.cc: New test. Tested x86_64-linux. Committed to trunk.