public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/102245] New: false int-in-bool-context warning with shift Date: Wed, 08 Sep 2021 21:36:36 +0000 [thread overview] Message-ID: <bug-102245-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102245 Bug ID: 102245 Summary: false int-in-bool-context warning with shift Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: #define shiftCB_DISABLE_FAULT_ON_UNMAPPED_ACCESS1 0 #define maskCB_DISABLE_FAULT_ON_UNMAPPED_ACCESS1 1L #define REG_FIELD_MASK(a,b) (mask##b) #define REG_FIELD_SHIFT(a,b) (shift##b) #define REG_SET_FIELD(orig_val, reg, field, field_val) \ (((orig_val) & ~REG_FIELD_MASK(reg, field)) | \ (REG_FIELD_MASK(reg, field) & ((field_val) << REG_FIELD_SHIFT(reg, field)))) int f(_Bool enable) { int tmp = 0; tmp = REG_SET_FIELD(tmp, VM_PRT_CNTL, CB_DISABLE_FAULT_ON_UNMAPPED_ACCESS1, enable); return tmp; } ------ CUT ---- Compile this on an ILP32 target with "-W -Wall -O2 -Werror -Werror=int-in-bool-context" and you get: <source>: In function 'f': <source>:10:53: error: '<<' in boolean context, did you mean '<'? [-Werror=int-in-bool-context] 10 | (REG_FIELD_MASK(reg, field) & ((field_val) << REG_FIELD_SHIFT(reg, field)))) | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <source>:17:9: note: in expansion of macro 'REG_SET_FIELD' 17 | tmp = REG_SET_FIELD(tmp, VM_PRT_CNTL, | ^~~~~~~~~~~~~ cc1: all warnings being treated as errors This is not correct as the shift is correct, I want to do a shift by 0 here and there is no boolean context at all. And it does not warn with LP64 targets either.
next reply other threads:[~2021-09-08 21:36 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-09-08 21:36 pinskia at gcc dot gnu.org [this message] 2021-09-08 21:48 ` [Bug c/102245] " pinskia at gcc dot gnu.org 2021-09-08 21:52 ` pinskia at gcc dot gnu.org 2021-09-08 21:55 ` [Bug c/102245] [12 Regression] " pinskia at gcc dot gnu.org 2021-09-08 22:14 ` jakub at gcc dot gnu.org 2021-09-08 22:38 ` jakub at gcc dot gnu.org 2021-09-09 7:37 ` rguenth at gcc dot gnu.org 2021-09-09 9:57 ` pinskia at gcc dot gnu.org 2021-09-13 10:45 ` roger at nextmovesoftware dot com 2021-09-14 7:56 ` roger at nextmovesoftware dot com 2021-09-17 14:58 ` cvs-commit at gcc dot gnu.org 2021-09-18 9:11 ` roger at nextmovesoftware dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-102245-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).