Issue 1138: Missing comparison-function parameter in bsearch_s

Authors: Jielun Wu
Date: 2026-11-27
Submitted against: C23
Status: Open

Paragraph 8 of the bsearch_s subclause gives its concrete external type with a two-parameter comparison-function type:

int (*)(const void *, const void *)

However, the synopsis in paragraph 1 declares a three-parameter comparison function, and paragraph 5 explicitly states that the third argument is the context argument passed to bsearch_s. The two-parameter type is incompatible with this interface, including when the generic macro is suppressed to access the actual function.

The error remains in N3998, K.3.6.4.2.

Suggested correction

In paragraph 8 of the bsearch_s subclause, add the missing void * parameter to the comparison-function type, so that the concrete type reads:

void * (const void *, const void *, rsize_t, rsize_t,
        int (*) (const void *, const void *, void *), void *)