Skip to content

Fixes error C4426 (optimization flags changed after including header) on MSVC#1971

Merged
ericniebler merged 1 commit intoNVIDIA:mainfrom
gamecentric:main
Mar 30, 2026
Merged

Fixes error C4426 (optimization flags changed after including header) on MSVC#1971
ericniebler merged 1 commit intoNVIDIA:mainfrom
gamecentric:main

Conversation

@gamecentric
Copy link
Copy Markdown
Contributor

According to Microsoft Learn the effects of pragma optimize with an empty string "" are the following

  • When you use the off parameter, it turns all the optimizations, g, s, t, and y, off.
  • When you use the on parameter, it resets the optimizations to the ones that you specified using the /O compiler option.

With the original code, the result of STDEXEC_PRAGMA_OPTIMIZE_BEGIN is always a no-op, while the effects of STDEXEC_PRAGMA_OPTIMIZE_END is to disable all optimizations. This makes compilation fail with a C4426 error if the library is included in a project where optimizations are enabled.
In MSVC the pragma cannot set a perfect equivalent of GCC "/O3" optimization level, so "t" (favor fast code) has been chosen as an alternative.

@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot bot commented Mar 30, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@ericniebler
Copy link
Copy Markdown
Collaborator

/ok to test 921e01f

@ericniebler ericniebler merged commit f0c6f54 into NVIDIA:main Mar 30, 2026
51 of 52 checks passed
@ericniebler
Copy link
Copy Markdown
Collaborator

thanks!

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