public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/66630] New: Missing ubsan/ftrapv error
@ 2015-06-22 16:46 mpolacek at gcc dot gnu.org
  2015-06-22 16:53 ` [Bug middle-end/66630] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-06-22 16:46 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 66630
           Summary: Missing ubsan/ftrapv error
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mpolacek at gcc dot gnu.org
  Target Milestone: ---

int
main (void)
{
  int i = -__INT_MAX__ - 1;
  int j = -i - 1;
  return j;
}

$ xgcc -fsanitize=undefined a.c; ./a.out

says nothing :(.  We should report the overflow when computing -i.


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

* [Bug middle-end/66630] Missing ubsan/ftrapv error
  2015-06-22 16:46 [Bug middle-end/66630] New: Missing ubsan/ftrapv error mpolacek at gcc dot gnu.org
@ 2015-06-22 16:53 ` pinskia at gcc dot gnu.org
  2015-06-22 16:55 ` mpolacek at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2015-06-22 16:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This might be because we convert -i - 1 to be ~i.


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

* [Bug middle-end/66630] Missing ubsan/ftrapv error
  2015-06-22 16:46 [Bug middle-end/66630] New: Missing ubsan/ftrapv error mpolacek at gcc dot gnu.org
  2015-06-22 16:53 ` [Bug middle-end/66630] " pinskia at gcc dot gnu.org
@ 2015-06-22 16:55 ` mpolacek at gcc dot gnu.org
  2015-06-23  8:22 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-06-22 16:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
That's one thing.  But there also something else going on.  I hope it's just
missing TYPE_OVERFLOW_SANITIZED in some match.pd patterns.


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

* [Bug middle-end/66630] Missing ubsan/ftrapv error
  2015-06-22 16:46 [Bug middle-end/66630] New: Missing ubsan/ftrapv error mpolacek at gcc dot gnu.org
  2015-06-22 16:53 ` [Bug middle-end/66630] " pinskia at gcc dot gnu.org
  2015-06-22 16:55 ` mpolacek at gcc dot gnu.org
@ 2015-06-23  8:22 ` rguenth at gcc dot gnu.org
  2021-07-19 22:54 ` pinskia at gcc dot gnu.org
  2024-04-03  4:59 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-06-23  8:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
For -ftrapv I never got around to commit some of the fixes I posted last
year...
(guard CCP properly for example).  Eventually at least CCP should be more
aggressive and simplify trapping stuff to __builtin_trap () (but the optab
implementations in libgcc use abort ()).


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

* [Bug middle-end/66630] Missing ubsan/ftrapv error
  2015-06-22 16:46 [Bug middle-end/66630] New: Missing ubsan/ftrapv error mpolacek at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2015-06-23  8:22 ` rguenth at gcc dot gnu.org
@ 2021-07-19 22:54 ` pinskia at gcc dot gnu.org
  2024-04-03  4:59 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-19 22:54 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |vincent-gcc at vinc17 dot net

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 87311 has been marked as a duplicate of this bug. ***

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

* [Bug middle-end/66630] Missing ubsan/ftrapv error
  2015-06-22 16:46 [Bug middle-end/66630] New: Missing ubsan/ftrapv error mpolacek at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-07-19 22:54 ` pinskia at gcc dot gnu.org
@ 2024-04-03  4:59 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-03  4:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Marek Polacek from comment #2)
> That's one thing.  But there also something else going on.  I hope it's just
> missing TYPE_OVERFLOW_SANITIZED in some match.pd patterns.

```
  /* ~A + A -> -1 */
  (simplify
   (plus:c (convert? (bit_not @0)) (convert? @0))
   (if (!TYPE_OVERFLOW_TRAPS (type))
    (convert { build_all_ones_cst (TREE_TYPE (@0)); })))

  /* ~A + 1 -> -A */
  (simplify
   (plus (convert? (bit_not @0)) integer_each_onep)
   (if (tree_nop_conversion_p (type, TREE_TYPE (@0)))
    (negate (convert @0))))

  /* -A - 1 -> ~A */
  (simplify
   (minus (convert? (negate @0)) integer_each_onep)
   (if (!TYPE_OVERFLOW_TRAPS (type)
        && TREE_CODE (type) != COMPLEX_TYPE
        && tree_nop_conversion_p (type, TREE_TYPE (@0)))
    (bit_not (convert @0))))

  /* -1 - A -> ~A */
  (simplify
   (minus integer_all_onesp @0)
   (if (TREE_CODE (type) != COMPLEX_TYPE)
    (bit_not @0)))

```

I am not sure which one of these patterns need the check for
TYPE_OVERFLOW_SANITIZED though.

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

end of thread, other threads:[~2024-04-03  4:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-22 16:46 [Bug middle-end/66630] New: Missing ubsan/ftrapv error mpolacek at gcc dot gnu.org
2015-06-22 16:53 ` [Bug middle-end/66630] " pinskia at gcc dot gnu.org
2015-06-22 16:55 ` mpolacek at gcc dot gnu.org
2015-06-23  8:22 ` rguenth at gcc dot gnu.org
2021-07-19 22:54 ` pinskia at gcc dot gnu.org
2024-04-03  4:59 ` 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).