https://docs.microsoft.com/en-us/cpp/porting/binary-compat-2015-2017?view=vs-2017 says that C++ Binary Compatibility between Visual Studio 2015 and Visual Studio 2017 is guaranteed except:
1)When static libraries or object files are compiled with the /GL compiler switch.
2)When consuming libraries built with a toolset whose version is greater than the toolset used to compile and link the application. For example, a program that is compiled and linked with compiler version 19.12 can consume libraries that are compiled with 19.0 up through 19.12. Also, binary compatibility only exists between Visual Studio 2015 and Visual Studio 2017; linking 19.x programs with libraries produced by Visual Studio 2013 or earlier is not supported.
Exception 2 makes me confused. Why binary compatibility can not be guaranteed in this case?
Let's make it be more specific. Provided a folder which contains a custom exe, a custom dll and part of vc_toolset dlls(v140 or v141). Both the custom exe and the custom dll are linked dynamically to part of vc_toolset dlls which includes CRT dlls, msvcp140.dll, vcruntime140.dll. Besides, /GL option is not enabled.
I list several combinations below. I wonder each one's binary compatibility.
1)exe built by vs2015 + dll built by vs2015 + v140 toolset dlls of vs2015
I think binary compatibility can be guaranteed in this case.
2)exe built by vs2015 + dll built by vs2015 + v141 toolset dlls of vs2017
based on case 1, additionally, toolset dlls were replaced with newer version that's shipped with vs2017.
Also, I think binary compatibility can be guaranteed in this case.
3)exe built by vs2015 + dll rebuilt by vs2017 + v140 toolset dlls of vs2015
base on case 1, the custom dll was rebuilt using vs2017. Then there are two choice:
a) just replace the dll and the exe would not be rebuilt using the new dll's import lib
b) replace the dll and rebuild the exe using the new dll's import lib.
According to the above link's exception 2, binary compatibility can not be guaranteed in a) and b) case. But why ? All the interfaces and dependencies of the custom dll are not changed, and it not rely on v141's new feature.
4)exe built by vs2015 + dll rebuilt by vs2017 + v141 toolset dlls of vs2017
base on case 3, additionally, toolset dlls were replaced with newer version that's shipped with vs2017.
5)exe rebuilt by vs2017 + dll built by vs2015 + v140 toolset dlls of vs2015
base on case 1, the custom exe was rebuilt using vs2017, and linked with the import lib of the custom dll which was previously built by vs2015
According to the above link, I think binary compatibility can be guaranteed in this case.
6)exe rebuilt by vs2017 + dll built by vs2015 + v141 toolset dlls of vs2017
base on case 5, additionally, toolset dlls were replaced with newer version that's shipped with vs2017. if case 5 and case 2 can be guaranteed, I think it's also guaranteed in this case.
Is my understanding correct?