https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103325

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-11-19
     Ever confirmed|0                           |1

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
I think we used to constant fold this as 1<<1.  GCC 7 does

> gcc-7 -S t.c -fdump-tree-original
t.c: In function 'main':
t.c:2:12: warning: right shift count is negative [-Wshift-count-negative]
   return 1 >> (-1);
            ^~
> cat t.c.003t.original 

;; Function main (null)
;; enabled by -tree-original


{
  return 2;
}
return 0;

but IIRC that behavior was removed from {int_const,wide}_int_binop at some
point, maybe also to enable sanitization.

gimple-ssa-isolate-paths.c would be one place to turn such code into
unreachable or traps (see other PRs to make the behavior configurable).

Reply via email to