Closed
Description
On Windows systems with a "utf8" locale, creating std::regex
objects for some regular expressions gets stuck. This problem is probably related to issues #441 and #810.
My R session is
R version 4.5.0 (2025-04-11 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)
Matrix products: default
LAPACK version 3.12.1
locale:
[1] LC_COLLATE=Italian_Italy.utf8 LC_CTYPE=Italian_Italy.utf8 LC_MONETARY=Italian_Italy.utf8 LC_NUMERIC=C LC_TIME=Italian_Italy.utf8
time zone: Europe/Rome
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.5.0 tools_4.5.0
and the snippet
Rcpp::cppFunction(
code = '
void test() {
std::regex simple("[a]");
}',
plugins = "cpp11",
includes = "#include <regex>"
)
test()
does not end. However, after setting LC_ALL to be "C", "Italian_Italy.1252", or "English_United States.1252", the same snippet works as expected. The problem can also be avoided by using the C++ function std::setlocale()
and setting the locale in the test()
code.
The issue does not appear to be related to the GNU library: the Rtools g++ can compile the test()
function, and the executable behaves as expected even when the locale uses UTF-8. My mingw terminal reports "it_IT.UTF-8" which is consistent with the locale of the R session.
Metadata
Metadata
Assignees
Labels
No labels