[cfe-dev] Regex/locale libcxx test failure on FreeBSD

Krzysztof Parzyszek via cfe-dev cfe-dev at lists.llvm.org
Fri Oct 14 17:38:37 PDT 2016


The test is
projects/libcxx/test/std/re/re.alg/re.alg.match/basic.pass.cpp

This assertion fails on FreeBSD:

     std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
     {
         std::cmatch m;
         const char s[] = "m";
         assert(std::regex_match(s, m, std::regex("[a[=M=]z]",
                                 std::regex_constants::basic)));


 From the looks of it, "m" should not match "[=M=]".  M is not a special 
letter in Czech, as far as I know, and the match is case-sensitive.

Libc seems to agree with this:

--- t.c ---
#include <locale.h>
#include <stdio.h>
#include <regex.h>

char errbuf[1024];

int main() {
   int r;
   regex_t re;
   regmatch_t m;

   setlocale(LC_COLLATE, "cs_CZ.ISO8859_2");

   r = regcomp(&re, "[a[=M=]z]", REG_BASIC);
   printf("regcomp=%d\n", r);

   r = regexec(&re, "m", 0, &m, 0);
   printf("regexec=%d\n", r);

   if (r != 0) {
     regerror(r, &re, errbuf, 1023);
     printf("error: %s\n", errbuf);
   }
}
-----------

clang t.c
./a.out

regcomp=0
regexec=1
error: regexec() failed to match


If the string in t.c is "M", it matches.

-Krzysztof



More information about the cfe-dev mailing list