Skip to content

tidbits: use C++ cmath functions#1

Merged
kadet1090 merged 1 commit into
freecad-masterfrom
fix-cmath-isinf-isnan
Jul 3, 2026
Merged

tidbits: use C++ cmath functions#1
kadet1090 merged 1 commit into
freecad-masterfrom
fix-cmath-isinf-isnan

Conversation

@tritao

@tritao tritao commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Use std::isinf and std::isnan from <cmath> in tidbits.cpp.
  • Preserve coin_isinf()'s documented -1 / +1 return contract with std::signbit.

Motivation

FreeCAD snap builds exposed a portability issue with GCC 13/C++20: Coin detects isinf and isnan through the C math.h header, but tidbits.cpp is C++ code including <cmath>, where the portable names are in the std:: namespace. Some environments do not expose the unqualified C names from <cmath>.

@tritao

tritao commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator Author

@kadet1090 Want to review and merge this one?

@kadet1090

Copy link
Copy Markdown
Member

I'm fine with the changes but not sure if we want to merge it before upstream had a change to look at it.

Comment thread src/tidbits.cpp
{
#ifdef HAVE_ISINF
return isinf(value);
if (std::isinf(value)) { return std::signbit(value) ? -1 : 1; }

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change actually fixes behavior here to match the documented function return value, which the previous version did not.

But upon an audit, this is not even used, at least on Linux, so there's not much risk of this correctness fix causing an issue.

@tritao

tritao commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator Author

I'm fine with the changes but not sure if we want to merge it before upstream had a change to look at it.

We need it to fix the snap build in FreeCAD, so I think we should merge it for now, especially since it's quite a basic fix.

If upstream wants changes to be done, we can just re-bump the submodule with those fixes.

But opened PR against upstream: coin3d#638

@kadet1090

Copy link
Copy Markdown
Member

Fine with me, won't be too much problem anyway.

@kadet1090 kadet1090 merged commit d566242 into freecad-master Jul 3, 2026
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.

2 participants