public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Uecker <ma.uecker@gmail.com>
To: Paul Koning <paulkoning@comcast.net>, Martin Sebor <msebor@gmail.com>
Cc: Michael Matz <matz@suse.de>, GCC Development <gcc@gcc.gnu.org>
Subject: Re: reordering of trapping operations and volatile
Date: Sun, 16 Jan 2022 13:37:13 +0100	[thread overview]
Message-ID: <24ecea0e5014c50976aa99d87333bc9054ae8817.camel@gmail.com> (raw)
In-Reply-To: <13B6017D-2A3D-4B45-A985-4A8269701178@comcast.net>

Am Samstag, den 15.01.2022, 16:38 -0500 schrieb Paul Koning:
> > On Jan 15, 2022, at 4:28 PM, Martin Sebor <msebor@gmail.com> wrote:
> > 
> > On 1/14/22 07:58, Paul Koning via Gcc wrote:
> > > > On Jan 14, 2022, at 9:15 AM, Michael Matz via Gcc <gcc@gcc.gnu.org> wrote:
> > > > 
> > > > > ...
> > > > But right now that's equivalent to making it observable,
> > > > because we don't have any other terms than observable or
> > > > undefined.  As aluded to later you would have to
> > > > introduce a new concept, something pseudo-observable,
> > > > which you then started doing.  So, see below.
> > > I find it really hard to view this notion of doing work for UB with any favor.  The way I see
> > > it is that a program having UB is synonymous with "defective program" and for the compiler to
> > > do extra work for these doesn't make much sense to me.
> > 
> > This is also the official position of the C committee on record,
> > but it's one that's now being challenged.

"nonportable or erroneous" is the official position.

> > > If the issue is specifically the handling of overflow traps, perhaps a better answer would be
> > > to argue for language changes that manage such events explicitly rather than having them be
> > > undefined behavior.  Another (similar) option might be to choose a language in which this is
> > > done.  (Is Ada such a language?  I don't remember.)
> > 
> > A change to the language standard is only feasible if it doesn't
> > overly constrain existing implementations. 
> 
> I was thinking that if a new feature is involved, rather than a new definition of behavior for
> existing code, it wouldn't be a constraint on existing implementations (in the sense of "what the
> compiler does for existing code written to the current rules").  In other words, suppose there was
> a concept of "trapping operations" that could be enabled by some new mechanism in the program
> text.  If you use that, then you're asking the compiler to do more work and your code may get
> slower or bigger.  But if you don't, the existing rules apply and nothing bad happens (other than
> that the compiler is somewhat larger and more complex due to the support for both cases).

There are also different proposal for doing something like this,
e.g. making certain undefined behaviour defined as trapping
operations, either as a language variant or by default.

But this is not my idea here, I want to limit the impact of UB
on defective programs - accepting the reality that in the real
world programs often have defects and any serious field of 
engineering needs to deal with this in a better way than to
say "the ISO standard says no requirements - so you loose".

Imagine an aurospace, biomedical, mechanical, or civil engineer
saying: " It makes no sense to consider for the case where one
part fails, this is then just then a defective
airplane/CT scanner/car/bridge.  Not worth spending extra
resources on it, and a non-defective airplane might potentially
be a little bit slower if we were to give you some guarantees
in this failure case. First you need to show that this has no
performance impact at all to anybody anywhere, then maybe we
consider this." (When, at the same time there is quite
substantial damage caused by defective C programs).

I thought limiting the impact of UB on previous defined I/O
would be a rather modest step towards more reliable software,
considering that this is already the case for most I/O and
it seems only some volatile accesses would need fixing (where
I still do not see how this could affect performance anywhere
where it actually matters). 


Martin





  reply	other threads:[~2022-01-16 12:37 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-08  8:32 Martin Uecker
2022-01-08 12:41 ` Richard Biener
2022-01-08 13:50   ` Martin Uecker
2022-01-08 14:13     ` Marc Glisse
2022-01-08 14:41     ` Eric Botcazou
2022-01-08 15:27       ` Martin Uecker
2022-01-08 17:33         ` Eric Botcazou
2022-01-08 15:03 ` David Brown
2022-01-08 16:42   ` Martin Uecker
2022-01-08 18:35 ` Andrew Pinski
2022-01-08 21:07   ` Martin Uecker
2022-01-10  9:04     ` Richard Biener
2022-01-10 17:36       ` Martin Uecker
2022-01-11  7:11         ` Richard Biener
2022-01-11  8:17           ` Martin Uecker
2022-01-11  9:13             ` Richard Biener
2022-01-11 20:01               ` Martin Uecker
2022-01-13 16:45                 ` Michael Matz
2022-01-13 19:17                   ` Martin Uecker
2022-01-14 14:15                     ` Michael Matz
2022-01-14 14:58                       ` Paul Koning
2022-01-15 21:28                         ` Martin Sebor
2022-01-15 21:38                           ` Paul Koning
2022-01-16 12:37                             ` Martin Uecker [this message]
2022-01-14 15:46                       ` Martin Uecker
2022-01-14 19:54                       ` Jonathan Wakely
2022-01-15  9:00                         ` Martin Uecker
2022-01-15 16:33                           ` Jonathan Wakely
2022-01-15 18:48                             ` Martin Uecker
2022-01-17 14:10                               ` Michael Matz
2022-01-18  8:31                                 ` Richard Biener
2022-01-21 16:21                                   ` Martin Uecker
2022-01-11 18:17           ` David Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=24ecea0e5014c50976aa99d87333bc9054ae8817.camel@gmail.com \
    --to=ma.uecker@gmail.com \
    --cc=gcc@gcc.gnu.org \
    --cc=matz@suse.de \
    --cc=msebor@gmail.com \
    --cc=paulkoning@comcast.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).