public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/108625] New: forwprop introduces new UB
@ 2023-02-01  9:10 kristerw at gcc dot gnu.org
  2023-02-01 21:49 ` [Bug tree-optimization/108625] [11/12/13 Regression] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: kristerw at gcc dot gnu.org @ 2023-02-01  9:10 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108625
           Summary: forwprop introduces new UB
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kristerw at gcc dot gnu.org
  Target Milestone: ---

Consider the function

  unsigned char foo(int x)
  {
    int t = -x;
    unsigned char t1 = t;
    unsigned char t2 = t;
    return t1 + t2;
  }

This does not invoke undefined behavior when called as foo(0x40000001),
but forwprop1 optimizes this to

  unsigned char foo (int x)
  {
    int t;
    unsigned char _5;
    int _7;

    <bb 2> :
    t_2 = -x_1(D);
    _7 = t_2 - x_1(D);
    _5 = (unsigned char) _7;
    return _5;
  }

where _7 has signed overflow for x = 0x40000001.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-05-02 12:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-01  9:10 [Bug tree-optimization/108625] New: forwprop introduces new UB kristerw at gcc dot gnu.org
2023-02-01 21:49 ` [Bug tree-optimization/108625] [11/12/13 Regression] " pinskia at gcc dot gnu.org
2023-02-02  9:58 ` rguenth at gcc dot gnu.org
2023-02-02 12:13 ` cvs-commit at gcc dot gnu.org
2023-02-02 12:14 ` [Bug tree-optimization/108625] [11/12 " rguenth at gcc dot gnu.org
2023-03-15  9:47 ` cvs-commit at gcc dot gnu.org
2023-05-02 12:03 ` [Bug tree-optimization/108625] [11 " cvs-commit at gcc dot gnu.org
2023-05-02 12:06 ` rguenth at gcc dot gnu.org

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).