Bug 35412 - Correctness with -ftrapv depended on libcall notes
Summary: Correctness with -ftrapv depended on libcall notes
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: unknown
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
: 39771 40143 (view as bug list)
Depends on: 101521 19020
Blocks: 35413
  Show dependency treegraph
 
Reported: 2008-02-29 23:23 UTC by Steven Bosscher
Modified: 2023-10-27 17:53 UTC (History)
7 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.3.1
Known to fail: 4.4.0
Last reconfirmed: 2009-04-14 20:08:33


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steven Bosscher 2008-02-29 23:23:36 UTC
See http://gcc.gnu.org/ml/gcc-patches/2007-10/msg01011.html

``When -ftrapv is in effect, libcalls are "necessary" so that the results of an operation can be propagated without making the call to the libgcc functions dead. The attached patch causes a failure in pr30286.c.''

This has to be investigated before libcall notes can be removed from the compiler.
Comment 1 Richard Biener 2008-02-29 23:33:53 UTC
-ftrapv is seriously broken and nobody wants to fix it;  so the most appealing
solution is to remove support for -ftrapv.  See PR19020, especially the
libcall part is broken as well.
Comment 2 Steven Bosscher 2008-02-29 23:36:51 UTC
PR19020 shows that -ftrapv vs. libcalls is broken even without Paolo's patch.
Comment 3 Paolo Bonzini 2008-05-31 09:18:30 UTC
Well, regression is a big word because -ftrapv is broken in general.  I guess the RM will lower the priority.
Comment 4 Richard Biener 2008-06-25 11:54:48 UTC
Not a regression.  $Summary was true always.
Comment 5 Joseph S. Myers 2008-07-04 19:42:32 UTC
Not a regression, removing milestone.
Comment 6 Andrew Pinski 2009-04-14 19:59:50 UTC
*** Bug 39771 has been marked as a duplicate of this bug. ***
Comment 7 Joost VandeVondele 2009-04-14 20:08:31 UTC
I'm reopening this report. -ftrapv is still documented, so can be expected to work by users. 

For the particular problem I have right now, a functional version of this option would be a great thing to have.
Comment 8 Richard Biener 2009-05-14 10:55:36 UTC
*** Bug 40143 has been marked as a duplicate of this bug. ***
Comment 9 R0b0t1 2017-05-08 17:36:39 UTC
Please fix. Per the documentation available `-fsantize=undefined` provides some of the missing functionality but does not allow the program's flow to be altered.
Comment 10 dingd 2023-03-05 14:20:07 UTC
I wonder what's the status of this bug. It has been 15 years.

As far as I know, Clang doesn't have this bug, so it should not be impossible to implement.

And, does -fsantize=undefined really provides the same functionality of this switch? I have always assumed that santizers are not to be used in production, right?
Comment 11 Andrew Pinski 2023-03-05 20:03:30 UTC
(In reply to dingd from comment #10)
> I wonder what's the status of this bug. It has been 15 years.

It still is a bug.

> 
> As far as I know, Clang doesn't have this bug, so it should not be
> impossible to implement.

Yes clang/LLVM does not have this bug because the internals of them and GCC are way different.

> 
> And, does -fsantize=undefined really provides the same functionality of this
> switch? I have always assumed that santizers are not to be used in
> production, right?

See PR 101521 for some ideas of how to implement this using the same infrastructure as -fsantize=undefined .