public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/13421] IA32 bigmem pointer subtraction and –ftrapv option causes unjustified program abort
       [not found] <bug-13421-4@http.gcc.gnu.org/bugzilla/>
@ 2021-12-29  6:12 ` pinskia at gcc dot gnu.org
  2023-06-25  2:01 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-29  6:12 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |oss at malat dot biz

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

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

* [Bug middle-end/13421] IA32 bigmem pointer subtraction and –ftrapv option causes unjustified program abort
       [not found] <bug-13421-4@http.gcc.gnu.org/bugzilla/>
  2021-12-29  6:12 ` [Bug middle-end/13421] IA32 bigmem pointer subtraction and –ftrapv option causes unjustified program abort pinskia at gcc dot gnu.org
@ 2023-06-25  2:01 ` pinskia at gcc dot gnu.org
  2024-04-30 11:05 ` cvs-commit at gcc dot gnu.org
  2024-05-02  6:33 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-25  2:01 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |baiwfg2 at gmail dot com

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

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

* [Bug middle-end/13421] IA32 bigmem pointer subtraction and –ftrapv option causes unjustified program abort
       [not found] <bug-13421-4@http.gcc.gnu.org/bugzilla/>
  2021-12-29  6:12 ` [Bug middle-end/13421] IA32 bigmem pointer subtraction and –ftrapv option causes unjustified program abort pinskia at gcc dot gnu.org
  2023-06-25  2:01 ` pinskia at gcc dot gnu.org
@ 2024-04-30 11:05 ` cvs-commit at gcc dot gnu.org
  2024-05-02  6:33 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-04-30 11:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #17 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:667c19de86b33648f5f4599f589a5e02adbb35cb

commit r15-67-g667c19de86b33648f5f4599f589a5e02adbb35cb
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Apr 16 14:05:35 2024 +0200

    middle-end/13421 - -ftrapv vs. POINTER_DIFF_EXPR

    Currently we expand POINTER_DIFF_EXPR using subv_optab when -ftrapv
    (but -fsanitize=undefined does nothing).  That's not consistent
    with the behavior of POINTER_PLUS_EXPR which never uses addv_optab
    with -ftrapv.  Both are because of the way we select whether to use
    the trapping or the non-trapping optab - we look at the result type
    of the expression and check

      trapv = INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_TRAPS (type);

    the bugreport correctly complains that -ftrapv affects pointer
    subtraction (there's no -ftrapv-pointer).  Now that we have
    POINTER_DIFF_EXPR we can honor that appropriately.

    The patch moves both POINTER_DIFF_EXPR and POINTER_PLUS_EXPR
    handling so they will never consider trapping (or saturating)
    optabs.

            PR middle-end/13421
            * optabs-tree.cc (optab_for_tree_code): Do not consider
            {add,sub}v or {us,ss}{add,sub} optabs for POINTER_DIFF_EXPR
            or POINTER_PLUS_EXPR.

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

* [Bug middle-end/13421] IA32 bigmem pointer subtraction and –ftrapv option causes unjustified program abort
       [not found] <bug-13421-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2024-04-30 11:05 ` cvs-commit at gcc dot gnu.org
@ 2024-05-02  6:33 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-02  6:33 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |15.0
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #18 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed for GCC 15.

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

* [Bug middle-end/13421] IA32 bigmem pointer subtraction and –ftrapv option causes unjustified program abort
  2003-12-17 16:33 [Bug c/13421] New: IA32 bigmem pointer subtraction and –ftrapv " vik dot heyndrickx at pandora dot be
@ 2004-04-06  5:13 ` eggert at twinsun dot com
  0 siblings, 0 replies; 5+ messages in thread
From: eggert at twinsun dot com @ 2004-04-06  5:13 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From eggert at twinsun dot com  2004-04-06 05:13 -------
A point of clarification: even if pointers are changed to be consistently
unsigned internally (which seems to be the right thing to do, if pointer
comparison is unsigned), GCC must still check for overflow when subtracting
pointers. For example, suppose we have the 2 GiB array "a" successfully
allocated by "char *a = malloc (1u<<31);". Then the expression "(a + (1u<<31)) -
a" is of type ptrdiff_t, which is a signed 32-bit integer that cannot represent
(1u<<31). So this expression must generate a trap with -ftrapv, regardless of
whether pointers are unsigned internally.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13421


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

end of thread, other threads:[~2024-05-02  6:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-13421-4@http.gcc.gnu.org/bugzilla/>
2021-12-29  6:12 ` [Bug middle-end/13421] IA32 bigmem pointer subtraction and –ftrapv option causes unjustified program abort pinskia at gcc dot gnu.org
2023-06-25  2:01 ` pinskia at gcc dot gnu.org
2024-04-30 11:05 ` cvs-commit at gcc dot gnu.org
2024-05-02  6:33 ` rguenth at gcc dot gnu.org
2003-12-17 16:33 [Bug c/13421] New: IA32 bigmem pointer subtraction and –ftrapv " vik dot heyndrickx at pandora dot be
2004-04-06  5:13 ` [Bug middle-end/13421] " eggert at twinsun dot com

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