I came across a the below peculiarity in gdb: the third argument to regcomp(3) appears mangled in gdb's output when I set a breakpoint and run it. Even though I pass 1 (i.e., REG_EXTENDED) to regcomp, gdb says that -809753220 was passed.
I see this behavior on 3.9 and a now rather of date 4.0 snapshot (at least a month or so old). Is this a bug in gdb, or is it some goofy (but expected) behavior caused by the linker resolving? Thanks. $ cat gdb-bug.c #include <regex.h> int main () { regex_t r; regcomp (&r, "foo", 1 /* REG_EXTENDED */); return 0; } $ cc -o gdb-bug gdb-bug.c -W -Wall -g $ gdb ./gdb-bug GNU gdb 6.3 Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-unknown-openbsd3.9"... (gdb) break regcomp Function "regcomp" not defined. Make breakpoint pending on future shared library load? (y or [n]) y Breakpoint 1 (regcomp) pending. (gdb) run Starting program: /tmp/gdb-bug Breakpoint 2 at 0x8349314: file /usr/src/lib/libc/regex/regcomp.c, line 162. Pending breakpoint "regcomp" resolved Breakpoint 2, regcomp (preg=0xcfbc25d0, pattern=0x3c000001 "foo", cflags=-809753220) at /usr/src/lib/libc/regex/regcomp.c:162 162 /usr/src/lib/libc/regex/regcomp.c: No such file or directory. in /usr/src/lib/libc/regex/regcomp.c (gdb) quit The program is running. Exit anyway? (y or n) y