Skip to content

Fix the AD build with the MSVC standard library - #3031

Merged
bigfooted merged 6 commits into
su2code:developfrom
KRGulaj:fix_msvc_stl_ad_build
Nov 30, 2026
Merged

bigfooted merged 6 commits into
su2code:developfrom
KRGulaj:fix_msvc_stl_ad_build

Conversation

@KRGulaj

@KRGulaj KRGulaj commented Nov 21, 2026

Copy link
Copy Markdown

Proposed Changes

The reverse and forward AD builds do not compile against the MSVC standard library. I build with clang-cl on Windows. There are two causes:

  1. std::isnan on su2double. The UCRT has a generic isnan template that wins over the CoDiPack overload, and it calls fpclassify, which only exists for floating-point types. The 8 calls in the turbomachinery averaging and output now use SU2_TYPE::GetValue(x), as the other NaN checks in SU2 do.
  2. std::complex<su2double>. The MSVC complex division and abs go through double. ad_structure.hpp already has su2double versions for macOS. They are now also used in MSVC AD builds.

Nothing changes for GCC, Clang or primal builds. CoDiPack's isnan also tests the passive value, so results do not change.

Related Work

Similar to #2900. The pinned CoDiPack version still includes <cxxabi.h>, which MSVC does not have; newer CoDiPack versions fix that.

PR Checklist

  • I am submitting my contribution to the develop branch.
  • My contribution generates no new compiler warnings (try with --warnlevel=3 when using meson).
  • My contribution is commented and consistent with SU2 style (https://su2code.github.io/docs_v7/Style-Guide/).
  • I used the pre-commit hook to prevent dirty commits and used pre-commit run --all to format old commits.
  • I have added a test case that demonstrates my contribution, if necessary. Not needed: results do not change, and existing cases run these lines.
  • I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp), if necessary. Not needed: no option changes.

Tests

  • clang-cl with the MSVC standard library: on develop, the reverse and forward AD builds fail with 7 errors in 3 files. With this PR both build.
  • Windows: the turbomachinery and harmonic balance cases give the same results as develop. The discrete adjoint turbomachinery cases run.
  • No new warnings with GCC and --warnlevel=3. The regression scripts and unit tests pass in SU2's CI Docker images.

With the MSVC STL, std::isnan on su2double resolves to the UCRT's generic
template, which does not compile. A NaN check only needs the value.
The generic complex division and abs of the MSVC STL convert to double.
Comment thread SU2_CFD/src/output/CFlowCompOutput.cpp Resolved
Comment thread SU2_CFD/src/output/CFlowCompOutput.cpp Resolved

@bigfooted bigfooted left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, can be merged as soon as CI passes

@bigfooted
bigfooted merged commit d98dec9 into su2code:develop Nov 30, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants