Fix test failures with newer msvc compilers (related to string aliasing) #4149
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix test failures with newer mscv compilers (related to string aliasing)
Context of Change
When building rippled on Windows with the latest msvc compilers & toolset (newer that Visual Studio 2017), there are string aliasing issues (demonstrated by this repo), where assigning a
constexpr
const char *
to astatic const char *
actually stores a pointer to a new string, so the two pointers don't compare equal (strcmp still works of course).This issue is seen only with specific flag combinations. I have seen it with the
/ZI
flag and the/Gy-
flag which disables Function-Level Linking.In order to avoid the issue altogether regardless if the compiler aliases strings, this change updates the code we don't do string pointer comparisons, but consistently use strcmp.
My suspicion is that the pointer comparisons should work, but we'd have to see where it is specified in the standard, otherwise we are just relying on UB. Anyways I have file a bug report with Microsoft, we'll see what they say. I also asked the question on stack overflow.
Type of Change