Page MenuHomeFreeBSD

stdlib.h: Fix qsort_r compatibility with GCC 12.
ClosedPublic

Authored by jhb on Nov 16 2022, 5:41 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 24, 1:55 PM
Unknown Object (File)
Sun, Apr 20, 12:48 AM
Unknown Object (File)
Sat, Apr 5, 1:27 PM
Unknown Object (File)
Sat, Apr 5, 12:43 PM
Unknown Object (File)
Mar 14 2025, 4:51 AM
Unknown Object (File)
Feb 25 2025, 8:47 AM
Unknown Object (File)
Feb 24 2025, 5:06 PM
Unknown Object (File)
Feb 24 2025, 6:18 AM
Subscribers

Details

Summary

GCC 12 (unlike GCC 9) does not match a function argument passed to the
old qsort_r() API (as is used in the qsort_r_compat test) to a
function pointer type via __generic. It treats the function type as a
distinct type from a function pointer. As a workaround, add a second
definition of qsort_r for GCC 12 which uses the bare function type.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 49169
Build 46058: arc lint + arc unit

Event Timeline

jhb requested review of this revision.Nov 16 2022, 5:41 PM

This breaks the build with clang as clang says a _Generic selector can only have an object type and a function pointer type isn't valid. GCC 9 was happy with the existing version, so this might be some regression in GCC 10, 11, or 12.

This is a bit of a stop-gap. I probably should create a smaller reproducible test case to submit as a bug upstream to GCC.

include/stdlib.h
355

I haven't tested GCC 10 or 11.

LGTM as it applies only to GCC 12.
Would be great to have a small reproducer shared with upstream.

This revision is now accepted and ready to land.Jan 19 2023, 7:10 PM