Fix build failure on mswin due to empty UNREACHABLE_RETURN()#398
Merged
Conversation
On MSVC, ruby.h expands UNREACHABLE_RETURN(val) to
`return (__assume(0), (val))`, so calling it without an argument
produces an empty parenthesized expression and fails to compile:
packer.h(421): error C2059: syntax error: ')'
GCC and Clang happen to accept the empty argument, which is why this
only surfaced on mswin. rb_raise is declared NORETURN so the hint is
redundant; drop it along with the Ruby 2.5 fallback definition.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes a Windows (MSVC) build failure caused by calling Ruby’s UNREACHABLE_RETURN() macro with no argument in ext/msgpack/packer.h. Since the error path already uses rb_raise (declared NORETURN), the explicit “unreachable” return hint is unnecessary and is removed along with the now-unused Ruby 2.5 fallback macro.
Changes:
- Removed the Ruby 2.5-only fallback
UNREACHABLE_RETURN()macro definition frompacker.h. - Removed the
UNREACHABLE_RETURN();invocation afterrb_raisein the oversized-string error path.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
byroot
approved these changes
Jul 10, 2026
Contributor
Author
|
@byroot Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Installing msgpack 1.8.3 on the x64-mswin64_140 platform fails to compile with the following error.
On MSVC, ruby.h expands
UNREACHABLE_RETURN(val)toreturn (__assume(0), (val)), so calling it without an argument produces an empty parenthesized expression that fails to parse. GCC and Clang happen to accept the empty argument, which is why this only surfaces on mswin.rb_raiseis declaredNORETURNso the unreachability hint is redundant. This removes the call along with the Ruby 2.5 fallback definition that existed only for it.With this change the extension builds with MSVC 14.51 and the test suite passes on Windows with 455 examples and 0 failures.