[Bug c/102245] [12 Regression] false int-in-bool-context warning with shift
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102245 Roger Sayle changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --- Comment #10 from Roger Sayle --- Fixed on mainline.
[Bug c/102245] [12 Regression] false int-in-bool-context warning with shift
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102245 --- Comment #9 from CVS Commits --- The master branch has been updated by Roger Sayle : https://gcc.gnu.org/g:2578a3870ef849dc77e98796600181b64ae4fd61 commit r12-3623-g2578a3870ef849dc77e98796600181b64ae4fd61 Author: Roger Sayle Date: Fri Sep 17 15:57:34 2021 +0100 PR c/102245: Disable sign-changing optimization for shifts by zero. Respecting Jakub's suggestion that it may be better to warn-on-valid for "if (x << 0)" as the author might have intended "if (x < 0)" [which will also warn when x is _Bool], the simplest way to resolve this regression is to disable the recently added fold transformation for shifts by zero; these will be optimized later (elsewhere). Guarding against integer_zerop is the simplest of three alternatives; the second being to only apply this transformation to GIMPLE and not GENERIC, and the third (potentially) being to explicitly handle shifts by zero here, with an (if cond then else), optimizing the expression to a convert, but awkwardly duplicating a more general transformation earlier in match.pd's shift simplifications. 2021-09-17 Roger Sayle gcc/ChangeLog PR c/102245 * match.pd (shift optimizations): Disable recent sign-changing optimization for shifts by zero, these will be folded later. gcc/testsuite/ChangeLog PR c/102245 * gcc.dg/Wint-in-bool-context-4.c: New test case.
[Bug c/102245] [12 Regression] false int-in-bool-context warning with shift
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102245 --- Comment #8 from Roger Sayle --- Alternate patch proposed: https://gcc.gnu.org/pipermail/gcc-patches/2021-September/579378.html
[Bug c/102245] [12 Regression] false int-in-bool-context warning with shift
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102245 Roger Sayle changed: What|Removed |Added CC||roger at nextmovesoftware dot com Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |roger at nextmovesoftware dot com --- Comment #7 from Roger Sayle --- Patch proposed: https://gcc.gnu.org/pipermail/gcc-patches/2021-September/579293.html
[Bug c/102245] [12 Regression] false int-in-bool-context warning with shift
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102245 --- Comment #6 from Andrew Pinski --- Here is a testcase which will hit the warning on all targets and not just ILP32 specific ones: int foo (_Bool x) { int v = 0; return (v & ~1u) | (1u & (x << 0)); }
[Bug c/102245] [12 Regression] false int-in-bool-context warning with shift
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102245 --- Comment #5 from Richard Biener --- I think the warning should work on unfolded (un-narrowed) trees or shorten_binary_op should from a INTEGER_TYPEd operation not create a BOOLEAN_TYPEd one (but maybe simply build a unsigned int:1 for it)?
[Bug c/102245] [12 Regression] false int-in-bool-context warning with shift
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102245 --- Comment #4 from Jakub Jelinek --- So, seems the binary context is result of shorten_binary_op, we see the 1L and (((int)x) << 0) operands of BIT_AND_EXPR, result_type is therefore long int and shorten_binary_op uses convert to convert that (((int)x) << 0) to long int and triggers the match.pd rule and folds it into (long int)x (where x has _Bool type). shorten_binary_op then decides to return _Bool type, which is why we have the bool context.
[Bug c/102245] [12 Regression] false int-in-bool-context warning with shift
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102245 Jakub Jelinek changed: What|Removed |Added Last reconfirmed||2021-09-08 Status|UNCONFIRMED |NEW CC||jakub at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #3 from Jakub Jelinek --- Started with r12-3073-g1d244020246cb155e4de62ca3b302b920a1f513f Deobfuscated testcase: int foo (_Bool x) { int v = 0; return (v & ~1L) | (1L & (x << 0)); }
[Bug c/102245] [12 Regression] false int-in-bool-context warning with shift
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102245 Andrew Pinski changed: What|Removed |Added Target Milestone|--- |12.0 Summary|false int-in-bool-context |[12 Regression] false |warning with shift |int-in-bool-context warning ||with shift