https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83601
Dominik Haumann <dhaumann at kde dot org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dhaumann at kde dot org --- Comment #4 from Dominik Haumann <dhaumann at kde dot org> --- If there is interest, another (smaller) test case would be: const std::string input = R"((.))"; const std::string expected = R"(\(\.\))"; const std::string obtained_std = std::regex_replace(input, std::regex(R"([.^$|()\[\]{}*+?\\])"), R"(\\&)", std::regex_constants::match_default | std::regex_constants::format_sed); const std::string obtained_boost = boost::regex_replace(input, boost::regex(R"([.^$|()\[\]{}*+?\\])"), R"(\\&)", boost::regex_constants::match_default | boost::regex_constants::format_sed); std::cout << "expected.......='" << expected << "'" << std::endl; std::cout << "obtained(std)..='" << obtained_std << "'" << std::endl; std::cout << "obtained(boost)='" << obtained_boost << "'" << std::endl; Output with GCC < 8: expected.......='\(\.\)' obtained(std)..='\\(\\(\\.\\)\\)' obtained(boost)='\(\(\.\)\)' With GCC >= 8, it works and it's the same as with boost.