public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][RFC] Enable -fstrict-overflow by default
@ 2017-04-24 11:39 Richard Biener
  2017-04-25 15:09 ` Jeff Law
  2017-04-26  8:52 ` Martin Sebor
  0 siblings, 2 replies; 9+ messages in thread
From: Richard Biener @ 2017-04-24 11:39 UTC (permalink / raw)
  To: gcc-patches


The following makes signed overflow undefined for all (non-)optimization
levels.  The intent is to remove -fno-strict-overflow signed overflow
behavior as that is not a sensible option to the user (it ends up
with the worst of both -fwrapv and -fno-wrapv).  The implementation
details need to be preserved for the forseeable future to not wreck
UBSAN with either associating (-fwrapv behavior) or optimizing
(-fno-wrapv behavior).

The other choice would be to make -fwrapv the default for -O[01].

A second patch in this series would unify -f[no-]wrapv, -f[no-]trapv
and -f[no-]strict-overflow with a 
-fsigned-integer-overflow={undefined,wrapping,trapping[,sanitized]}
option, making conflicts amongst the options explicit (and reduce
the number of flag_ variables).  'sanitized' would essentially map
to todays flag_strict_overflow = 0.  There's another sole user
of flag_strict_overflow, POINTER_TYPE_OVERFLOW_UNDEFINED - not sure
what to do about that, apart from exposing it as different flag
alltogether.

Further patches in the series would remove -Wstrict-overflow (and
cleanup VRP for example).

Anyway, most controversical part(?) below.

Any comments on this particular patch (and the overall proposal)?

Cleaning up the options is probably a no-brainer anyways.

Thanks,
Richard.

2017-04-24  Richard Biener  <rguenther@suse.de>

	* common.opt (fstrict-overflow): Enable by default.
	* opts.c (default_options_table): Remove OPT_fstrict_overflow entry.

Index: gcc/common.opt
===================================================================
--- gcc/common.opt	(revision 247091)
+++ gcc/common.opt	(working copy)
@@ -2342,7 +2342,7 @@ Common Report Var(flag_strict_aliasing)
 Assume strict aliasing rules apply.
 
 fstrict-overflow
-Common Report Var(flag_strict_overflow) Optimization
+Common Report Var(flag_strict_overflow) Init(1) Optimization
 Treat signed overflow as undefined.
 
 fsync-libcalls
Index: gcc/opts.c
===================================================================
--- gcc/opts.c	(revision 247091)
+++ gcc/opts.c	(working copy)
@@ -496,7 +496,6 @@ static const struct default_options defa
     { OPT_LEVELS_2_PLUS, OPT_fschedule_insns2, NULL, 1 },
 #endif
     { OPT_LEVELS_2_PLUS, OPT_fstrict_aliasing, NULL, 1 },
-    { OPT_LEVELS_2_PLUS, OPT_fstrict_overflow, NULL, 1 },
     { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_freorder_blocks_algorithm_, NULL,
       REORDER_BLOCKS_ALGORITHM_STC },
     { OPT_LEVELS_2_PLUS, OPT_freorder_functions, NULL, 1 },

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

end of thread, other threads:[~2017-04-28  3:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-24 11:39 [PATCH][RFC] Enable -fstrict-overflow by default Richard Biener
2017-04-25 15:09 ` Jeff Law
2017-04-25 15:14   ` Richard Biener
2017-04-25 15:23     ` Jeff Law
2017-04-26  8:52 ` Martin Sebor
2017-04-26  9:13   ` Richard Biener
2017-04-26 17:14     ` Martin Sebor
2017-04-27  9:23       ` Richard Biener
2017-04-28  6:45         ` Martin Sebor

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