This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Optimisations and undefined behaviour
- From: Andrew Haley <aph at redhat dot com>
- To: David Brown <david dot brown at hesbynett dot no>, Richard Earnshaw <Richard dot Earnshaw at foss dot arm dot com>, Florian Weimer <fweimer at redhat dot com>
- Cc: Segher Boessenkool <segher at kernel dot crashing dot org>, "[gcc-help]" <gcc-help at gcc dot gnu dot org>
- Date: Mon, 9 Nov 2015 16:31:21 +0000
- Subject: Re: Optimisations and undefined behaviour
- Authentication-results: sourceware.org; auth=none
- References: <563BC190 dot 7080406 at hesbynett dot no> <563C7EB6 dot 9050401 at redhat dot com> <563C9DD3 dot 9030407 at hesbynett dot no> <563F9E4C dot 5000504 at redhat dot com> <20151108193430 dot GA28206 at gate dot crashing dot org> <56407162 dot 7050106 at redhat dot com> <56408D14 dot 2090101 at redhat dot com> <5640A8D3 dot 8060706 at redhat dot com> <5640AAC5 dot 9090509 at redhat dot com> <5640ADC5 dot 4090604 at redhat dot com> <5640B40C dot 9000906 at foss dot arm dot com> <5640B51F dot 1080401 at redhat dot com> <5640B632 dot 9040802 at foss dot arm dot com> <5640BA3E dot 3030508 at redhat dot com> <5640C248 dot 7040904 at hesbynett dot no>
On 11/09/2015 03:56 PM, David Brown wrote:
> We typically cannot use "sanatize" options, nor can we accept that a
> bug in one part of the program causes undue and unnecessarily
> damaging side-effects in other parts.
Well, you have to get used to that. It is reality: computers work
that way. I'm sure you know that if you hit the wrong I/O port
with a wild write odd things will happen. Whether that's "undue" or
"unnecessary" I couldn't say: it just is.
C definitely works that way. Maybe there should be a nice small
language which is useful for embedded developers and doesn't have
all the interesting UB properties that C has. (Ada, maybe? Probably
not.) Maybe you could define a language compatible with C with the UB
removed. But defining the semantics of such a language would not be
easy. And I don't think it makes much sense to change GCC without
such a rigorous language definition.
Andrew.