http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51297
--- Comment #9 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2011-11-24 23:31:06 UTC --- > Hm, can you try the attached patch? It avoids passing a null pointer, which > is > not permitted. Passing zero as nmemb is permitted (7.20.5 para 1 of c99). > So > I'm a little puzzled as to why bsearch managed to call the comparison > function > at all. I'd like to understand if we're dealing with a weird, but legal, > implementation, or one that's got a bug. The patch solves the problem for me.