This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of CD1 status.

405. qsort and POD

Section: 27.12 [alg.c.library] Status: CD1 Submitter: Ray Lischner Opened: 2003-04-08 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [alg.c.library].

View all issues with CD1 status.


Section 27.12 [alg.c.library] describes bsearch and qsort, from the C standard library. Paragraph 4 does not list any restrictions on qsort, but it should limit the base parameter to point to POD. Presumably, qsort sorts the array by copying bytes, which requires POD.

Proposed resolution:

In 27.12 [alg.c.library] paragraph 4, just after the declarations and before the nonnormative note, add these words: "both of which have the same behavior as the original declaration. The behavior is undefined unless the objects in the array pointed to by base are of POD type."

[Something along these lines is clearly necessary. Matt provided wording.]