Skip to content

Fix r-value ref miscompile on MSVC v19.22.#41

Merged
martinmoene merged 2 commits into
nonstd-lite:masterfrom
jacobly0:fix/msvc
Dec 9, 2021
Merged

Fix r-value ref miscompile on MSVC v19.22.#41
martinmoene merged 2 commits into
nonstd-lite:masterfrom
jacobly0:fix/msvc

Conversation

@jacobly0

@jacobly0 jacobly0 commented Dec 7, 2021

Copy link
Copy Markdown
Contributor

Returning an r-value reference through the comma operator is miscompiled by MSVC v19.22, as evidenced here.

Examples of tests failures without the expected.hpp changes on MSVC v19.16:

expected-lite\test\expected.t.cpp(1812): failed: pr-41: *std::move(a) == 7 for -858993460 == 7
expected-lite\test\expected.t.cpp(1813): failed: pr-41: std::move(b).error() == 7 for -858993460 == 7
expected-lite\test\expected.t.cpp(1814): failed: pr-41: std::move(c).error() == 7 for -858993460 == 7

@martinmoene

Copy link
Copy Markdown
Collaborator

Thanks for your PR.

The comma expression is/was used for C++11 constexpr-ness.

Correctness comes first naturally.

Have to think a bit what approach I'd like.

@jacobly0

jacobly0 commented Dec 9, 2021

Copy link
Copy Markdown
Contributor Author

That's what I get for not checking clang warnings. Since l-value refs aren't affected, the simplest solution is to just rearrange the expression.

@martinmoene martinmoene merged commit 3abf068 into nonstd-lite:master Dec 9, 2021
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