Skip to content

Fix build failure on mswin due to empty UNREACHABLE_RETURN()#398

Merged
byroot merged 1 commit into
msgpack:masterfrom
hsbt:claude/vigilant-chebyshev-63ce11
Jul 10, 2026
Merged

Fix build failure on mswin due to empty UNREACHABLE_RETURN()#398
byroot merged 1 commit into
msgpack:masterfrom
hsbt:claude/vigilant-chebyshev-63ce11

Conversation

@hsbt

@hsbt hsbt commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Installing msgpack 1.8.3 on the x64-mswin64_140 platform fails to compile with the following error.

packer.h(421): warning C4003: not enough arguments for function-like macro invocation 'RBIMPL_UNREACHABLE_RETURN'
packer.h(421): error C2059: syntax error: ')'

On MSVC, ruby.h expands UNREACHABLE_RETURN(val) to return (__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_raise is declared NORETURN so 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.

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>
Copilot AI review requested due to automatic review settings July 10, 2026 02:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 from packer.h.
  • Removed the UNREACHABLE_RETURN(); invocation after rb_raise in the oversized-string error path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@byroot byroot merged commit 8ab8a5a into msgpack:master Jul 10, 2026
19 checks passed
@hsbt

hsbt commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

@byroot Thanks!

@hsbt hsbt deleted the claude/vigilant-chebyshev-63ce11 branch July 10, 2026 05:21
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.

3 participants