Skip to content
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

Fix test failures with newer msvc compilers (related to string aliasing) #4149

Closed
wants to merge 4 commits into from

Conversation

greg7mdp
Copy link
Contributor

@greg7mdp greg7mdp commented Apr 21, 2022

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 a static 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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Tests (You added tests for code that already exists, or your new feature included in this PR)
  • Documentation Updates
  • Release

src/ripple/rpc/impl/RPCHelpers.cpp Outdated Show resolved Hide resolved
src/ripple/rpc/impl/RPCHelpers.cpp Outdated Show resolved Hide resolved
@greg7mdp greg7mdp changed the title Fix test failures with newer mscv compilers (related to string aliasing) Fix test failures with newer msvc compilers (related to string aliasing) Apr 27, 2022
src/ripple/rpc/impl/RPCHelpers.cpp Outdated Show resolved Hide resolved
src/ripple/rpc/impl/RPCHelpers.cpp Outdated Show resolved Hide resolved
src/ripple/rpc/impl/RPCHelpers.cpp Outdated Show resolved Hide resolved
src/ripple/rpc/impl/RPCHelpers.cpp Outdated Show resolved Hide resolved
src/ripple/rpc/impl/RPCHelpers.cpp Outdated Show resolved Hide resolved
src/ripple/rpc/impl/RPCHelpers.cpp Outdated Show resolved Hide resolved
This was referenced May 10, 2022
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