Project

General

Profile

Actions

Bug #17946

closed

win32/win32.c: `&` has lower precedence than `==`

Added by xtkoba (Tee KOBAYASHI) almost 3 years ago. Updated almost 3 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:104232]

Description

A warning in win32/win32.c:2600:

../win32/win32.c:2606:88: warning: & has lower precedence than ==; == will be evaluated first [-Wparentheses]
                *(pend + (sizeof(FUNCTION_BEFORE_RET_MARK) - 1) + FUNCTION_SKIP_BYTES) & FUNCTION_RET == FUNCTION_RET) {
                                                                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../win32/win32.c:2606:88: note: place parentheses around the '==' expression to silence this warning
                *(pend + (sizeof(FUNCTION_BEFORE_RET_MARK) - 1) + FUNCTION_SKIP_BYTES) & FUNCTION_RET == FUNCTION_RET) {
                                                                                       ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../win32/win32.c:2606:88: note: place parentheses around the & expression to evaluate it first
                *(pend + (sizeof(FUNCTION_BEFORE_RET_MARK) - 1) + FUNCTION_SKIP_BYTES) & FUNCTION_RET == FUNCTION_RET) {
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~

I believe this is not intentional because FUNCTION_RET == FUNCTION_RET is a tautology.

Updated by jeremyevans0 (Jeremy Evans) almost 3 years ago

Thank you for pointing this out. I agree that parentheses must have been intended in this case. I submitted a pull request to add them: https://github.com/ruby/ruby/pull/4575

Actions #2

Updated by jeremyevans (Jeremy Evans) almost 3 years ago

  • Status changed from Open to Closed

Applied in changeset git|7c31ecd3accd75d164b4f87b0651b47f31da286d.


Add parentheses to avoid pointless condition

Pointed out by xtkoba (Tee KOBAYASHI).

Fixes [Bug #17946]

Actions

Also available in: Atom PDF

Like0
Like0Like0