Skip to content

Include <cstdlib> where free() is used in polyxx - #117

Merged
ahmed-irfan merged 2 commits into
masterfrom
fix-polyxx-cstdlib-116
Nov 19, 2026
Merged

ahmed-irfan merged 2 commits into
masterfrom
fix-polyxx-cstdlib-116

Conversation

@ahmed-irfan

Copy link
Copy Markdown
Member

Fixes #116.

src/polyxx/polynomial.cpp, upolynomial.cpp and utils.cpp call free() without including a header that declares it. They only compiled because another standard header happened to pull in <cstdlib>; libc++ 23 no longer does, so the build fails with use of undeclared identifier 'free'.

This adds #include <cstdlib> to the three files. No other changes.

Testing: the existing ctest suite passes (16/16) on Apple clang 17. I could not reproduce the original failure on this toolchain (it depends on libc++ 23's header layout), so no regression test is added.

🤖 Generated with Claude Code

polynomial.cpp, upolynomial.cpp and utils.cpp call free() without
including a header that declares it, relying on transitive includes.
libc++ 23 no longer provides <cstdlib> that way, so the build fails
with "use of undeclared identifier 'free'".

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@ahmed-irfan
ahmed-irfan merged commit 5718075 into master Nov 19, 2026
16 checks passed
@ahmed-irfan
ahmed-irfan deleted the fix-polyxx-cstdlib-116 branch November 19, 2026 19:24
ajreynol pushed a commit to ajreynol/cvc5 that referenced this pull request Nov 20, 2026
libc++ 23 changed two implementation details that break the build:

- Its headers no longer include `<vector>` transitively, so
`preprocessing_pass_registry.h`, which uses `std::vector` without
including `<vector>`, fails to compile. This PR adds the missing
include.
- It provides `std::hash` for integer types through the primary template
instead of explicit specializations. The configure probe for
`CVC5_NEED_HASH_UINT64_T_OVERLOAD` inferred that `std::hash<uint64_t>`
is missing whenever an explicit specialization of it compiles. Under
libc++ 23 the probe passes, and `util/hash.h` then specializes
`std::hash<uint64_t>` after the standard library has already
instantiated it. Since C++11, the standard library must provide
`std::hash` for all integer types, so this PR removes the probe and the
fallback specialization. Both date back to 2012 (c0377cd), when they
targeted the non-standard `__gnu_cxx::hash` of GNU's `hash_map`
extension, and they have been obsolete since the move to C++11's
`std::hash` in 2017 (8b0659e), which converted them by renaming the
namespace.

Both problems come from libc++, not from the compiler: clang 23 with
libstdc++ is unaffected.

Tested with clang 23.1.5 and libc++ 23 (LLVM release binaries) in a
debug build, where all unit tests and all `regress0` tests pass. For
that run, libpoly needed a local patch, because its C++ wrapper also
calls `free` without including `<cstdlib>`. That problem is in libpoly
and is not addressed here; it is fixed upstream by SRI-CSL/libpoly#117,
which is not yet part of a libpoly release.

Fixes cvc5#13188.
Fixes cvc5#13189.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

polyxx: free() is used without <cstdlib>; the build fails with clang 23 and libc++

1 participant