Weird regex behavior on 9.1-RELEASE on amd64 in 32-bit mode

Michael Sperber sperber at deinprogramm.de
Tue Jul 9 18:08:35 UTC 2013


I noticed that scsh (which only runs in 32-bit mode) fails on amd64.  I
narrowed it down to a regex malfunction (I think).  This program:

----snip----
#include <regex.h>
#include <stdio.h>

int
main(void)
{
  regex_t r;
  int status = regcomp(&r, "/afs", REG_EXTENDED);
  size_t nmatch   = 1 + r.re_nsub;
  regmatch_t pmatch[32];
  status = regexec(&r, "/afs/informatik", nmatch, pmatch, 0);
  {
    int i;
    for(i = 0; i < nmatch; i--) {
      printf("%d: %d - %d\n", i, (int) pmatch[i].rm_so, (int) pmatch[i].rm_eo);
    }
  }
  return 0;
}
----snip----

This giveds me:

# gcc r.c
# ./a.out
0: 0 - 4
# gcc -m32 r.c
# ./a.out
0: 0 - 0

Is it me or is there a bug?  Help would be much appreciated!

-- 
Regards,
Mike



More information about the freebsd-stable mailing list