-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MSVC: Add –d2UndefIntOverflow– #1396
Comments
Does anybody know how to do this? |
Well tried using latest VS 2022: Project properties -> C/C++ -> Command line -> added |
I bit the bullet and booted my dual boot machine into windows to do some experimentation this morning. Using the same method of adding the flag to Commandline like GPUex /d2UndefIntOverflow- does not work but /UndefIntOverflow- does. I assume it does the same thing. if I search for UndefIntOverflow in the msvc docs I get no results with or without d2. https://lectem.github.io/msvc/reverse-engineering/build/2019/01/21/MSVC-hidden-flags.html lists /UndefIntOverflow+ and /UndefIntOverflow- as hidden flags but not versions with d2 in them. My understanding is that d2 indicates which stage of compilation the flag effects and as far as I can see it seems this is generally or always only used for hidden flags not meant for public consumption. So my guess is that they decided to make UndefIntOverflow publicly available at some point and renamed the internal flag but haven't finalized things and actually put the flag in the documentation yet (and that they may or may not have just forgotten about the whole thing). So really old versions of visual studio prior to that devlog from 2016 likely don't support the option at all. The first version likely supports it with the d2 prefix and then at some point the prefix is dropped which is the state for the latest version. @jedisct1 So as I see it we could:
I recommend 1 or 2. I believe 2 would just be a minor change to the libsodium.vcxproj file: ...
<ClCompile>
<AdditionalOptions>/UndefIntOverflow- %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
... |
When using zig/clang/gcc, we unconditionally enable
-fwrapv
in order make overflowing signed operations well defined.But this is not the case when using MSVC.
–d2UndefIntOverflow–
is a compiler flag equivalent to-fwrapv
: https://devblogs.microsoft.com/cppblog/new-code-optimizer/We should figure out how to enable it in the Visual Studio solutions.
The text was updated successfully, but these errors were encountered: