10000 intern.h: mark rb_num_zerodiv as NORETURN by xiw · Pull Request #147 · ruby/ruby · GitHub
[go: up one dir, main page]

Skip to content

intern.h: mark rb_num_zerodiv as NORETURN #147

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
intern.h: mark rb_num_zerodiv as NORETURN
Consider the following code in time.c (quo).

    if (b == 0) rb_num_zerodiv();
    c = a / b;

This patch informs the compiler that rb_num_zerodiv doesn't return.
Otherwise some compilers may conclude that the division a / b is always
reachable, leading to misoptimization.
  • Loading branch information
xiw committed Jul 17, 2012
commit e16200f20be95535b71b1d5c5da361093bc3cd97
2 changes: 1 addition & 1 deletion include/ruby/intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ VALUE rb_marshal_dump(VALUE, VALUE);
VALUE rb_marshal_load(VALUE);
void rb_marshal_define_compat(VALUE newclass, VALUE oldclass, VALUE (*dumper)(VALUE), VALUE (*loader)(VALUE, VALUE));
/* numeric.c */
void rb_num_zerodiv(void);
NORETURN(void rb_num_zerodiv(void));
#define RB_NUM_COERCE_FUNCS_NEED_OPID 1
VALUE rb_num_coerce_bin(VALUE, VALUE, ID);
VALUE rb_num_coerce_cmp(VALUE, VALUE, ID);
Expand Down
0