Skip to content

Fix a -Wreturn-type warning#843

Closed
k0kubun wants to merge 1 commit into
ruby:masterfrom
k0kubun:fix-warning
Closed

Fix a -Wreturn-type warning#843
k0kubun wants to merge 1 commit into
ruby:masterfrom
k0kubun:fix-warning

Conversation

@k0kubun
Copy link
Copy Markdown
Member

@k0kubun k0kubun commented Aug 27, 2025

This PR fixes a warning in ruby/ruby builds:

../../../../ext/json/generator/generator.c: In function ‘cState_allow_duplicate_key_p’:
../../../../ext/json/generator/generator.c:1852:1: warning: control reaches end of non-void function [-Wreturn-type]
 1852 | }
      | ^

case JSON_RAISE:
return Qfalse;
default:
return Qnil;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hum, this should be unreachable. Let me see if I can mark it as such.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I wasn't sure if C extensions have access to rb_bug or portable assert implementations. That's why I didn't use one, but yeah let's do so if you have an idea.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wasn't sure if C extensions have access

They do, but not sure how much of it really is intended to be exposed. So I merged a slightly modified version of your patch: d3f7f04

@byroot byroot closed this in d3f7f04 Aug 27, 2025
@k0kubun k0kubun deleted the fix-warning branch August 27, 2025 18:52
hsbt pushed a commit to hsbt/ruby that referenced this pull request Sep 3, 2025
Fix: ruby/json#843

ruby/json@d3f7f0452b

Co-Authored-By: Takashi Kokubun <takashikkbn@gmail.com>
hsbt pushed a commit to ruby/ruby that referenced this pull request Sep 3, 2025
Fix: ruby/json#843

ruby/json@d3f7f0452b

Co-Authored-By: Takashi Kokubun <takashikkbn@gmail.com>
byroot added a commit to RubyElders/json that referenced this pull request Oct 27, 2025
Fix: ruby#843

Co-Authored-By: Takashi Kokubun <takashikkbn@gmail.com>
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