public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug sanitizer/113726] New: sanitizer reports signed overflow but not underflow
@ 2024-02-02 17:18 jetrull at sbcglobal dot net
  2024-02-02 17:26 ` [Bug middle-end/113726] sanitizer reports signed overflow but not underflow for constant folding case pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: jetrull at sbcglobal dot net @ 2024-02-02 17:18 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113726
           Summary: sanitizer reports signed overflow but not underflow
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jetrull at sbcglobal dot net
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org
  Target Milestone: ---

This code produces both a warning and a sanitizer failure:

    long result = std::numeric_limits<long>::max() + 1l;

This code produces only a compiler warning:

    long result = std::numeric_limits<long>::min() - 1l;

The Clang sanitizer flags both operations.

This seems to be true for several versions, including 11.4 (my laptop) and
trunk.

https://godbolt.org/z/9nf3hhWsM

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

* [Bug middle-end/113726] sanitizer reports signed overflow but not underflow for constant folding case
  2024-02-02 17:18 [Bug sanitizer/113726] New: sanitizer reports signed overflow but not underflow jetrull at sbcglobal dot net
@ 2024-02-02 17:26 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-02 17:26 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|sanitizer                   |middle-end
            Summary|sanitizer reports signed    |sanitizer reports signed
                   |overflow but not underflow  |overflow but not underflow
                   |                            |for constant folding case
      Known to fail|                            |14.0, 5.1.0
   Last reconfirmed|                            |2024-02-02
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed. It is constant folding ...

Reduced testcase:
```

int main() {
    long result = (-__LONG_MAX__ - 1);
    result -= 1l; // sanitizer reports this 
    result = (-__LONG_MAX__ - 1) - 1; // But NOT this
    __builtin_printf("%ld\n", result);
}

```

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

end of thread, other threads:[~2024-02-02 17:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-02 17:18 [Bug sanitizer/113726] New: sanitizer reports signed overflow but not underflow jetrull at sbcglobal dot net
2024-02-02 17:26 ` [Bug middle-end/113726] sanitizer reports signed overflow but not underflow for constant folding case pinskia 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).