Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Elliptic paraboloids for sale.


devel / comp.arch / Re: Paper about ISO C

SubjectAuthor
* Paper about ISO Cclamky
+- Re: Paper about ISO CBGB
+* Re: Paper about ISO CDavid Brown
|+* Re: Paper about ISO CBGB
||+* Re: Paper about ISO CMitchAlsup
|||+* Re: Paper about ISO CMitchAlsup
||||`* Re: Paper about ISO CBranimir Maksimovic
|||| `* Re: Paper about ISO CGeorge Neuner
||||  +- Re: Paper about ISO CBranimir Maksimovic
||||  `* Re: Paper about ISO CEricP
||||   `* Re: Paper about ISO CIvan Godard
||||    `* Re: Paper about ISO CEricP
||||     `* Re: Paper about ISO CMitchAlsup
||||      +* Re: Paper about ISO CBGB
||||      |`* Re: Paper about ISO CStephen Fuld
||||      | +* Re: Paper about ISO CIvan Godard
||||      | |+* Re: addressing and protection, was Paper about ISO CJohn Levine
||||      | ||+* Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |||+- Re: addressing and protection, was Paper about ISO CJohn Levine
||||      | |||+* Re: addressing and protection, was Paper about ISO CIvan Godard
||||      | ||||`- Re: addressing and protection, was Paper about ISO CQuadibloc
||||      | |||`- Re: addressing and protection, was Paper about ISO CBill Findlay
||||      | ||`* Re: addressing and protection, was Paper about ISO CQuadibloc
||||      | || +- Re: addressing and protection, was Paper about ISO CStephen Fuld
||||      | || `- Re: addressing and protection, was Paper about ISO CBranimir Maksimovic
||||      | |`* Re: addressing and protection, was Paper about ISO CEricP
||||      | | +* Re: addressing and protection, was Paper about ISO CStefan Monnier
||||      | | |`- Re: addressing and protection, was Paper about ISO CEricP
||||      | | `* Re: addressing and protection, was Paper about ISO CIvan Godard
||||      | |  +* Re: addressing and protection, was Paper about ISO CBGB
||||      | |  |+* Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  ||`* Re: addressing and protection, was Paper about ISO CBGB
||||      | |  || `* Re: addressing and protection, was Paper about ISO CJohn Dallman
||||      | |  ||  +* Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  ||  |+- Re: addressing and protection, was Paper about ISO CBGB
||||      | |  ||  |+* Re: addressing and protection, was Paper about ISO CThomas Koenig
||||      | |  ||  ||`* Re: addressing and protection, was Paper about ISO CBGB
||||      | |  ||  || `* Re: addressing and protection, was Paper about ISO CAnton Ertl
||||      | |  ||  ||  `- Re: addressing and protection, was Paper about ISO CBGB
||||      | |  ||  |`* Re: addressing and protection, was Paper about ISO CQuadibloc
||||      | |  ||  | +- Re: addressing and protection, was Paper about ISO CQuadibloc
||||      | |  ||  | `- Re: addressing and protection, was Paper about ISO CBGB
||||      | |  ||  `- Re: addressing and protection, was Paper about ISO CBGB
||||      | |  |`* Re: addressing and protection, was Paper about ISO CJohn Dallman
||||      | |  | +* Re: addressing and protection, was Paper about ISO CThomas Koenig
||||      | |  | |`* Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  | | `* Re: addressing and protection, was Paper about ISO CThomas Koenig
||||      | |  | |  +* Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  | |  |+* Re: addressing and protection, was Paper about ISO CStefan Monnier
||||      | |  | |  ||+- Re: addressing and protection, was Paper about ISO CChris M. Thomasson
||||      | |  | |  ||+* Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  | |  |||`- Re: addressing and protection, was Paper about ISO CThomas Koenig
||||      | |  | |  ||+* Re: addressing and protection, was Paper about ISO CThomas Koenig
||||      | |  | |  |||`* Re: addressing and protection, was Paper about ISO CEricP
||||      | |  | |  ||| `- Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  | |  ||`- Re: addressing and protection, was Paper about ISO CJohn Dallman
||||      | |  | |  |`- Re: addressing and protection, was Paper about ISO CThomas Koenig
||||      | |  | |  `* Re: addressing and protection, was Paper about ISO CIvan Godard
||||      | |  | |   +- Re: addressing and protection, was Paper about ISO CBGB
||||      | |  | |   `* Re: addressing and protection, was Paper about ISO CStephen Fuld
||||      | |  | |    +* Address space consumption (was: addressing and protection, was Paper about ISO CStefan Monnier
||||      | |  | |    |`- Re: Address space consumption (was: addressing and protection, wasMitchAlsup
||||      | |  | |    +* Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  | |    |`- Re: addressing and protection, was Paper about ISO CThomas Koenig
||||      | |  | |    `* Re: addressing and protection, was Paper about ISO CGeorge Neuner
||||      | |  | |     `* Re: addressing and protection, was Paper about ISO CStephen Fuld
||||      | |  | |      +* Re: addressing and protection, was Paper about ISO CMichael S
||||      | |  | |      |`* Re: addressing and protection, was Paper about ISO CTerje Mathisen
||||      | |  | |      | `- Re: addressing and protection, was Paper about ISO CMichael S
||||      | |  | |      `* Re: addressing and protection, was Paper about ISO CStefan Monnier
||||      | |  | |       +* Re: addressing and protection, was Paper about ISO CBGB
||||      | |  | |       |`* Re: addressing and protection, was Paper about ISO CJohn Levine
||||      | |  | |       | +* Re: addressing and protection, was Paper about ISO CBGB
||||      | |  | |       | |`* Re: addressing and protection, was Paper about ISO CStephen Fuld
||||      | |  | |       | | `* Re: addressing and protection, was Paper about ISO CBGB
||||      | |  | |       | |  `* Re: addressing and protection, was Paper about ISO CJohn Levine
||||      | |  | |       | |   +- Re: addressing and protection, was Paper about ISO CBGB
||||      | |  | |       | |   +- Re: addressing and protection, was Paper about ISO Cclamky
||||      | |  | |       | |   `* Re: addressing and protection, was Paper about ISO CGeorge Neuner
||||      | |  | |       | |    +* Re: addressing and protection, was Paper about ISO CBGB
||||      | |  | |       | |    |`* Re: addressing and protection, was Paper about ISO CGeorge Neuner
||||      | |  | |       | |    | +* Re: addressing and protection, was Paper about ISO CBGB
||||      | |  | |       | |    | |+* Re: addressing and protection, was Paper about ISO CIvan Godard
||||      | |  | |       | |    | ||+* Re: educational computation, was addressing and protection, was Paper about ISO John Levine
||||      | |  | |       | |    | |||`* Re: educational computation, was addressing and protection, was PaperIvan Godard
||||      | |  | |       | |    | ||| `- Re: educational computation, was addressing and protection, was PaperTerje Mathisen
||||      | |  | |       | |    | ||`* Re: addressing and protection, was Paper about ISO CBGB
||||      | |  | |       | |    | || `* Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  | |       | |    | ||  +- Re: addressing and protection, was Paper about ISO CBGB
||||      | |  | |       | |    | ||  `- Re: addressing and protection, was Paper about ISO CDavid Brown
||||      | |  | |       | |    | |+- Re: addressing and protection, was Paper about ISO CBGB
||||      | |  | |       | |    | |`* Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  | |       | |    | | +* Re: addressing and protection, was Paper about ISO CBGB
||||      | |  | |       | |    | | |+- Re: addressing and protection, was Paper about ISO CIvan Godard
||||      | |  | |       | |    | | |`* Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  | |       | |    | | | +* Re: addressing and protection, was Paper about ISO CIvan Godard
||||      | |  | |       | |    | | | |+* Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  | |       | |    | | | ||`- Re: addressing and protection, was Paper about ISO CJimBrakefield
||||      | |  | |       | |    | | | |`* Re: addressing and protection, was Paper about ISO CTerje Mathisen
||||      | |  | |       | |    | | | | `* Re: addressing and protection, was Paper about ISO CTim Rentsch
||||      | |  | |       | |    | | | |  `- Re: addressing and protection, was Paper about ISO CTerje Mathisen
||||      | |  | |       | |    | | | +* Re: addressing and protection, was Paper about ISO CBGB
||||      | |  | |       | |    | | | `- Re: addressing and protection, was Paper about ISO CTerje Mathisen
||||      | |  | |       | |    | | `- Re: addressing and protection, was Paper about ISO CAnne & Lynn Wheeler
||||      | |  | |       | |    | `- Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  | |       | |    `* Re: what is cheap these days, addressing and protection, was Paper about ISO CJohn Levine
||||      | |  | |       | +* Re: addressing and protection, was Paper about ISO CStephen Fuld
||||      | |  | |       | +* Re: addressing and protection, was Paper about ISO CMichael S
||||      | |  | |       | `* Re: addressing and protection, was Paper about ISO CMichael S
||||      | |  | |       +* RAM size (was: addressing and protection, was Paper about ISO C)Anton Ertl
||||      | |  | |       `- Re: addressing and protection, was Paper about ISO CTerje Mathisen
||||      | |  | +* Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  | `* Re: addressing and protection, was Paper about ISO CJohn Levine
||||      | |  +* Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  `* Re: addressing and protection, was Paper about ISO CJohn Levine
||||      | `* Re: Paper about ISO CBGB
||||      `- Re: Paper about ISO CEricP
|||+* Re: Paper about ISO CBranimir Maksimovic
|||+* Re: Paper about ISO CThomas Koenig
|||+* Re: Paper about ISO Cantispam
|||`- Re: Paper about ISO CQuadibloc
||+* Re: Paper about ISO CThomas Koenig
||`* Re: Paper about ISO CDavid Brown
|+* Re: Paper about ISO CThomas Koenig
|`* Re: Paper about ISO CVictor Yodaiken
`* Re: Paper about ISO CKent Dickey

Pages:123456789101112131415161718192021222324252627282930313233
Re: Specifying timing constraints was Re: Paper about ISO C

<skjshe$2up$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21325&group=comp.arch#21325

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.arch
Subject: Re: Specifying timing constraints was Re: Paper about ISO C
Date: Mon, 18 Oct 2021 15:23:57 +0200
Organization: A noiseless patient Spider
Lines: 66
Message-ID: <skjshe$2up$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk9ej9$fj9$1@dont-email.me> <jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org>
<skc7a9$698$1@dont-email.me> <skc905$85c$1@dont-email.me>
<skh20o$ji2$1@dont-email.me>
<4fc4f707-2d42-492a-bd41-f791141dbfb2n@googlegroups.com>
<skhjk3$9p4$1@dont-email.me>
<f9db2e75-2ec2-4572-b211-a8b2d6b3e0e6n@googlegroups.com>
<skjkqv$nd3$1@dont-email.me>
<0ba079c3-d672-47b3-b86d-cfc74520ca5dn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 18 Oct 2021 13:23:58 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="e675145544f77b1e34fd66ac3bfc48ce";
logging-data="3033"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18oUaHKSm83buzV32twN6F34BA6gRvq9yQ="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:OSfCzwmcw5+OUGzphBpNdJ6ltEU=
In-Reply-To: <0ba079c3-d672-47b3-b86d-cfc74520ca5dn@googlegroups.com>
Content-Language: en-GB
 by: David Brown - Mon, 18 Oct 2021 13:23 UTC

On 18/10/2021 14:45, Michael S wrote:
> On Monday, October 18, 2021 at 2:12:34 PM UTC+3, David Brown wrote:

>> Back here in the real world, if programmers stopped writing silly code
>> then there would be a lot fewer software problems to go around.
>
> Don't be silly.
> The best solution does not involve magic.
> Something like that will do:
>
> Signed overflow is implementation-defined, but in constrained way.
> Possible options are
> 1. two-complement wrap-around
> 2. trap
> 3. saturation
> 4. one-complement wrap-around, if there exist a member of committee that care about it
> Implementation has to specify the chosen option clearly in documentation. It is allowed to select an option
> with special flag. It is not allowed to make option dependent on optimization settings.
> If the chosen option is trap and overflow happens in intermediate result of complex expression, but not in the final result than it's it's legal for trap to be intermittent and dependent on ether optimization level or phase of the moon, but not both.
>

That is not an attitude I would accept in a programmer working for me.
(I'd accept - and correct - ignorance. That's a different matter.)

I will happily accept a trapping option as a temporary choice while
chasing a bug. I will happily accept specific behaviour, coded
/correctly/, in cases where specific behaviour is appropriate and
correct - in some algorithms, saturation is the desired behaviour, and
in a few cases modulo behaviour is the model you want. These can be
written correctly in C without any undefined behaviour, special flags,
limited compilers, sacrificing of black cockerels, or whatever other
effort you make in order to make incorrect code give the results you want.

But anyone who tells me that their own particular interpretation of what
happens on signed integer overflow is "the one right answer", "the
obvious choice", "the most efficient choice", "what C used to do", or
anything on that line - that person is going to have a hard time trying
to justify themselves. And if they tell me "it worked when I tried it",
I'll know their code reviews will take a lot longer.

Coding is, for the most part, a matter of defining and calling functions
(as a general term, this includes operators). Every function has a
pre-condition that the caller ensures is true before calling the
function, and a post-condition that the function ensures is true before
returning. The function can - and generally must - assume the
pre-condition is true at the start of the function, just as the caller
can assume the post-condition is true at the return.

Thus if you give the function appropriate inputs, you can expect the
desired output. If you give it invalid inputs, you can't have any
reasonable expectations about what comes out. Garbage in, garbage out.
It is the programmer's job to ensure that he or she does not put
garbage in.

And in the case of signed integer arithmetic, it is the programmer's job
to ensure that the input to expressions will not cause an overflow. It
is /not/ the compiler's job to ensure that if garbage is put in, the
garbage that comes out should always smell of roses.

You can argue until you are blue in the face that you think signed
integer arithmetic overflow /should/ be defined, whether you have a
particular idea for how it should be defined, or you just want it to do
"something". There are languages where it /is/ defined. In C, it is
/not/ defined. Accept that, or use a different language. End of story.

Re: Specifying timing constraints was Re: Paper about ISO C

<86ee8ilafk.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21326&group=comp.arch#21326

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.arch
Subject: Re: Specifying timing constraints was Re: Paper about ISO C
Date: Mon, 18 Oct 2021 06:38:55 -0700
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <86ee8ilafk.fsf@linuxsc.com>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me> <afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com> <3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com> <sk6s4a$9cm$1@dont-email.me> <1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com> <sk9ej9$fj9$1@dont-email.me> <jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org> <skc7a9$698$1@dont-email.me> <skc905$85c$1@dont-email.me> <skh20o$ji2$1@dont-email.me> <4fc4f707-2d42-492a-bd41-f791141dbfb2n@googlegroups.com> <skhjk3$9p4$1@dont-email.me> <f9db2e75-2ec2-4572-b211-a8b2d6b3e0e6n@googlegroups.com> <skjkqv$nd3$1@dont-email.me> <66a62215-19ef-42bf-a1df-004bb766600bn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="8ee1acb52a8112476d820ed421c6cd41";
logging-data="32145"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/jDnmg4eH3NCQj8+dMzZAVl53rNNVaSKs="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:OyTs/P3BI0aKwOAPIDRDURsL7eY=
sha1:7R3V6+c6x2TZIWQb8XTtycBc5o4=
 by: Tim Rentsch - Mon, 18 Oct 2021 13:38 UTC

Michael S <already5chosen@yahoo.com> writes:

[..considering code examples..]

if ((x < 1) || (x > 3)) __builtin_unreachable();
y = z / x;

[..or alternative..]

if (x == 1) {
y = 1;
} else if (x == 2) {
y = z / 2;
} else {
y = z / 3;
}

[..(end code examples)..]

> I'd very much prefer
> y = x > 1 && x < 4 ? z/x : z;

+1

> Depending on distribution of x, it can be either faster or slower
> or the same as [the first example], but is fully-defined, does not
> depend on gcc extensions and, IMHO, is easier to grasp.

+1

(Linguistic nit: no hyphen between "fully" and "defined". In
most cases there is no hyphen between an adverb and a following
adjective.)

Re: Specifying timing constraints was Re: Paper about ISO C

<8af10f0d-80ae-4cf2-b2e1-048a72bef192n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21327&group=comp.arch#21327

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ac8:5f82:: with SMTP id j2mr9328631qta.35.1634564890642;
Mon, 18 Oct 2021 06:48:10 -0700 (PDT)
X-Received: by 2002:a05:6830:1ae3:: with SMTP id c3mr22081872otd.144.1634564890420;
Mon, 18 Oct 2021 06:48:10 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Mon, 18 Oct 2021 06:48:10 -0700 (PDT)
In-Reply-To: <skjshe$2up$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com> <3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me> <1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk9ej9$fj9$1@dont-email.me> <jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org>
<skc7a9$698$1@dont-email.me> <skc905$85c$1@dont-email.me> <skh20o$ji2$1@dont-email.me>
<4fc4f707-2d42-492a-bd41-f791141dbfb2n@googlegroups.com> <skhjk3$9p4$1@dont-email.me>
<f9db2e75-2ec2-4572-b211-a8b2d6b3e0e6n@googlegroups.com> <skjkqv$nd3$1@dont-email.me>
<0ba079c3-d672-47b3-b86d-cfc74520ca5dn@googlegroups.com> <skjshe$2up$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8af10f0d-80ae-4cf2-b2e1-048a72bef192n@googlegroups.com>
Subject: Re: Specifying timing constraints was Re: Paper about ISO C
From: already5...@yahoo.com (Michael S)
Injection-Date: Mon, 18 Oct 2021 13:48:10 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 83
 by: Michael S - Mon, 18 Oct 2021 13:48 UTC

On Monday, October 18, 2021 at 4:24:00 PM UTC+3, David Brown wrote:
> On 18/10/2021 14:45, Michael S wrote:
> > On Monday, October 18, 2021 at 2:12:34 PM UTC+3, David Brown wrote:
>
> >> Back here in the real world, if programmers stopped writing silly code
> >> then there would be a lot fewer software problems to go around.
> >
> > Don't be silly.
> > The best solution does not involve magic.
> > Something like that will do:
> >
> > Signed overflow is implementation-defined, but in constrained way.
> > Possible options are
> > 1. two-complement wrap-around
> > 2. trap
> > 3. saturation
> > 4. one-complement wrap-around, if there exist a member of committee that care about it
> > Implementation has to specify the chosen option clearly in documentation. It is allowed to select an option
> > with special flag. It is not allowed to make option dependent on optimization settings.
> > If the chosen option is trap and overflow happens in intermediate result of complex expression, but not in the final result than it's it's legal for trap to be intermittent and dependent on ether optimization level or phase of the moon, but not both.
> >
> That is not an attitude I would accept in a programmer working for me.
> (I'd accept - and correct - ignorance. That's a different matter.)
>
> I will happily accept a trapping option as a temporary choice while
> chasing a bug. I will happily accept specific behaviour, coded
> /correctly/, in cases where specific behaviour is appropriate and
> correct - in some algorithms, saturation is the desired behaviour, and
> in a few cases modulo behaviour is the model you want. These can be
> written correctly in C without any undefined behaviour, special flags,

First, it is true that modulo is what I really want, but I leave other options open.

Second, I don't think that modulo behavior can be easily achieved in legalistic dialect of C.
In "solutions" that I had seen there are rat hole near assignment of certain unsigned rvalues
to signed lvalue and even bigger hole in handling of multiplication.

Third, even if it's possible, there are other dimensions apart from legalism.
One is aesthetic (it's ugly) and other is ergonomic (it's error prone).

> limited compilers, sacrificing of black cockerels, or whatever other
> effort you make in order to make incorrect code give the results you want.
>
> But anyone who tells me that their own particular interpretation of what
> happens on signed integer overflow is "the one right answer", "the
> obvious choice", "the most efficient choice", "what C used to do", or
> anything on that line - that person is going to have a hard time trying
> to justify themselves. And if they tell me "it worked when I tried it",
> I'll know their code reviews will take a lot longer.
>
> Coding is, for the most part, a matter of defining and calling functions
> (as a general term, this includes operators). Every function has a
> pre-condition that the caller ensures is true before calling the
> function, and a post-condition that the function ensures is true before
> returning. The function can - and generally must - assume the
> pre-condition is true at the start of the function, just as the caller
> can assume the post-condition is true at the return.
>
> Thus if you give the function appropriate inputs, you can expect the
> desired output. If you give it invalid inputs, you can't have any
> reasonable expectations about what comes out. Garbage in, garbage out.
> It is the programmer's job to ensure that he or she does not put
> garbage in.
>
> And in the case of signed integer arithmetic, it is the programmer's job
> to ensure that the input to expressions will not cause an overflow. It
> is /not/ the compiler's job to ensure that if garbage is put in, the
> garbage that comes out should always smell of roses.
>

From a person that never complains about C Standard definition of "unsigned"
that sounds more than a bit hypocritical.

>
> You can argue until you are blue in the face that you think signed
> integer arithmetic overflow /should/ be defined, whether you have a
> particular idea for how it should be defined, or you just want it to do
> "something". There are languages where it /is/ defined. In C, it is
> /not/ defined. Accept that, or use a different language. End of story.

I am not sure.
It can be fixed in the future. The pressure is applied all the time and by far more influential people than myself.

Re: Specifying timing constraints was Re: Paper about ISO C

<86a6j6l8ci.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21328&group=comp.arch#21328

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.arch
Subject: Re: Specifying timing constraints was Re: Paper about ISO C
Date: Mon, 18 Oct 2021 07:23:57 -0700
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <86a6j6l8ci.fsf@linuxsc.com>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me> <afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com> <3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com> <sk6s4a$9cm$1@dont-email.me> <1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com> <sk9ej9$fj9$1@dont-email.me> <jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org> <skc7a9$698$1@dont-email.me> <skc905$85c$1@dont-email.me> <skh20o$ji2$1@dont-email.me> <4fc4f707-2d42-492a-bd41-f791141dbfb2n@googlegroups.com> <skhjk3$9p4$1@dont-email.me> <f9db2e75-2ec2-4572-b211-a8b2d6b3e0e6n@googlegroups.com> <skjkqv$nd3$1@dont-email.me> <0ba079c3-d672-47b3-b86d-cfc74520ca5dn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="8ee1acb52a8112476d820ed421c6cd41";
logging-data="6709"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+4bEpIXB6IbtPEodjVLUytEEhCoK+dkjw="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:QasywoBbCTKuUv5AuGhA4ok2ID0=
sha1:OZa2hhRUn4OhUjrlPjFn9DdlKIc=
 by: Tim Rentsch - Mon, 18 Oct 2021 14:23 UTC

Michael S <already5chosen@yahoo.com> writes:

>> [..sarcastic comments regarding signed overflow..]

> Don't be silly.
> The best solution does not involve magic.
> Something like that will do:
>
> Signed overflow is implementation-defined, but in constrained way.
> Possible options are
> 1. two-complement wrap-around
> 2. trap
> 3. saturation
> 4. one-complement wrap-around, if there exist a member of
> committee that care about it
>
> Implementation has to specify the chosen option clearly in
> documentation. It is allowed to select an option with special
> flag. It is not allowed to make option dependent on optimization
> settings. If the chosen option is trap and overflow happens in
> intermediate result of complex expression, but not in the final
> result than it's it's legal for trap to be intermittent and
> dependent on ether optimization level or phase of the moon, but
> not both.

My sense is this idea is not much better than how things are
now. I would like to see the decision be under control of
the source code, perhaps by means of a #pragma:

#pragma STDC SIGNED_OVERFLOW WRAP
#pragma STDC SIGNED_OVERFLOW TRAP
#pragma STDC SIGNED_OVERFLOW SATURATE
#pragma STDC SIGNED_OVERFLOW UNDEFINED
(..others?..)

If it's important, implementations might be allowed not to
implement some or all of these choices; but if they don't then
they must at least check the #pragma line for legality and fail
the compilation if they cannot accommodate the choice indicated
(or if the #pragma STDC doesn't scan for some reason).

Re: Specifying timing constraints was Re: Paper about ISO C

<skk58k$f4q$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21329&group=comp.arch#21329

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.arch
Subject: Re: Specifying timing constraints was Re: Paper about ISO C
Date: Mon, 18 Oct 2021 17:52:52 +0200
Organization: A noiseless patient Spider
Lines: 87
Message-ID: <skk58k$f4q$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk9ej9$fj9$1@dont-email.me> <jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org>
<skc7a9$698$1@dont-email.me> <skc905$85c$1@dont-email.me>
<skh20o$ji2$1@dont-email.me>
<4fc4f707-2d42-492a-bd41-f791141dbfb2n@googlegroups.com>
<skhjk3$9p4$1@dont-email.me>
<f9db2e75-2ec2-4572-b211-a8b2d6b3e0e6n@googlegroups.com>
<skjkqv$nd3$1@dont-email.me>
<66a62215-19ef-42bf-a1df-004bb766600bn@googlegroups.com>
<skjr8q$mh4$1@dont-email.me>
<137ec286-ccc2-4b1f-bc53-881242272b7an@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 18 Oct 2021 15:52:52 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="e675145544f77b1e34fd66ac3bfc48ce";
logging-data="15514"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/nbBpBSb9ytoyDGxCCOli6aGBP8e1/Y+M="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:Asc4urIEVZgX+e9FNE7hYIWA1Vc=
In-Reply-To: <137ec286-ccc2-4b1f-bc53-881242272b7an@googlegroups.com>
Content-Language: en-GB
 by: David Brown - Mon, 18 Oct 2021 15:52 UTC

On 18/10/2021 15:21, Michael S wrote:
> On Monday, October 18, 2021 at 4:02:21 PM UTC+3, David Brown wrote:
>> On 18/10/2021 14:23, Michael S wrote:
>>> On Monday, October 18, 2021 at 2:12:34 PM UTC+3, David Brown wrote:
>>>> On 18/10/2021 01:47, Victor Yodaiken wrote:
>>>>> On Sunday, October 17, 2021 at 11:39:37 AM UTC-5, David Brown wrote:
>>
>>>>>> If I tell the compiler "assume x is between 1 and 3", what do you think
>>>>>> should happen if it is /not/ in that range?
>>>>>>
>>>>>> Perhaps I have code:
>>>>>>
>>>>>> if ((x < 1) || (x > 3)) __builtin_unreachable();
>>>>>> y = z / x;
>>>>>>
>>
>>>
>>> I'd very much prefer
>>> y = x > 1 && x < 4 ? z/x : z;
>>> Depending on distribution of x, it can be either faster or slower or the same as your variant, but is fully-defined, does not depend on gcc extensions and, IMHO, is easier to grasp.
>>>
>> A quick test will show you that my version is faster -
>
> So, do it.
> I can't test it myself, because right now I have no HW on my table on which division is much slower than branch mispredict.
> Don't forget to test a distribution in which x==1 occures much more often than 2 and 3.

Use <https://godbolt.org>.

Of course, on your particular hardware the less efficient code might not
translate into a difference in real execution speed - and execution
speed is not always important. On my targets - small, relatively simple
processors - extra instructions means extra time.

>
>> a compiler will
>> either make use of the extra information in order to give more efficient
>> results, or it will ignore the test entirely and give you the same as
>> plain "y = z / x;". Your version (after correcting to "x >= 1"),
>
> No need to correct anything. My version is correct as written.
>

Sorry, yes, I see what you mean. However, the whole point of the
exercise is /not/ manual micro-optimisations. It is to give the
compiler more information, and let the /compiler/ optimise. Of course
in this particular example it would be possible to write manual
optimisation, in which case it would not be done the way you did it.
Imagine it was real code, and you had "x_min" and "x_max", defined as
constants somewhere far off in a header, rather than 1 and 3.

>> on the
>> other hand, /forces/ the compiler to make the comparison, and any
>> optimisations it might have been able to apply to the "z/x" bit could be
>> applied in my version.
>>
>> Your version is not fully defined for all x - it is undefined if x is 0.
>
> Wrong. For x=0 it returns z.

Yes, again I read a little too quickly. Yes it is defined - it gives a
meaningless result for invalid input. That does not matter, there is no
need to give any kind of result for invalid input.

>
>> It /is/ fully defined on the specified input range with x from 1 to 3,
>> but so is mine. Being defined for values of x that cannot occur is of
>> no benefit whatsoever.
>>
>> Your version does not depend on a gcc extension, that is certainly true
>> - there is no good portable way to give the compiler such extra
>> information (that was my point).
>>
>> Easier to grasp is, of course, in the eye of the reader.
>>
>> In practice, I have such tests wrapped in a macro, and thus write :
>>
>> assume((x >= 1) && (x <= 3));
>> y = z / x;
>> If the compiler can tell at compile-time that the assumption is wrong,
>> it gives me an error message. If I want to check it at run-time, I set
>> a pre-processor symbol (like DEBUG for standard "assert") to choose such
>> checking.

Re: Specifying timing constraints was Re: Paper about ISO C

<skk5h9$gth$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21330&group=comp.arch#21330

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.arch
Subject: Re: Specifying timing constraints was Re: Paper about ISO C
Date: Mon, 18 Oct 2021 17:57:29 +0200
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <skk5h9$gth$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk9ej9$fj9$1@dont-email.me> <jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org>
<skc7a9$698$1@dont-email.me> <skc905$85c$1@dont-email.me>
<skh20o$ji2$1@dont-email.me>
<4fc4f707-2d42-492a-bd41-f791141dbfb2n@googlegroups.com>
<skhjk3$9p4$1@dont-email.me>
<f9db2e75-2ec2-4572-b211-a8b2d6b3e0e6n@googlegroups.com>
<skjkqv$nd3$1@dont-email.me>
<0ba079c3-d672-47b3-b86d-cfc74520ca5dn@googlegroups.com>
<875ytupjzd.fsf@hotmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 18 Oct 2021 15:57:29 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="e675145544f77b1e34fd66ac3bfc48ce";
logging-data="17329"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/GtEANxd8owiQEPkR0hdUMQsRp2YwctAg="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:fDLaoU7VvnfDQSmeXN3+HoA9Ybg=
In-Reply-To: <875ytupjzd.fsf@hotmail.com>
Content-Language: en-GB
 by: David Brown - Mon, 18 Oct 2021 15:57 UTC

On 18/10/2021 14:59, clamky@hotmail.com wrote:
> Michael S <already5chosen@yahoo.com> writes:
>
>> On Monday, October 18, 2021 at 2:12:34 PM UTC+3, David Brown wrote:
>>> On 18/10/2021 01:47, Victor Yodaiken wrote:
>>>> On Sunday, October 17, 2021 at 11:39:37 AM UTC-5, David Brown wrote:
>>>>> On 17/10/2021 16:40, Victor Yodaiken wrote:
>>>>>> On Sunday, October 17, 2021 at 6:39:07 AM UTC-5, David Brown wrote:
>>>>>>
>
> [..]
>
>>> Back here in the real world, if programmers stopped writing silly code
>>> then there would be a lot fewer software problems to go around.
>>
>> Don't be silly.
>> The best solution does not involve magic.
>> Something like that will do:
>>
>> Signed overflow is implementation-defined, but in constrained way.
>
> I think that is what standard calls "unspecified behavior"

No, "unspecified behaviour" is entirely different.

Signed overflow is covered in 6.5p5:

"""
If an exceptional condition occurs during the evaluation of an
expression (that is, if the result is not mathematically defined or not
in the range of representable values for its type), the behavior is
undefined.
"""

"Unspecified behaviour" could mean (for example) that adding two ints
would always give you a valid int - it's just that you would not know
/which/ int you get if you had an overflow.

"Unspecified" is used for things like the order of evaluation for "a +
b" - it is unspecified which is evaluated first. (That means the
compiler doesn't need to document it - it doesn't even need to be
consistent from run to run.)

Re: Specifying timing constraints was Re: Paper about ISO C

<skk6h7$ovp$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21331&group=comp.arch#21331

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.arch
Subject: Re: Specifying timing constraints was Re: Paper about ISO C
Date: Mon, 18 Oct 2021 18:14:30 +0200
Organization: A noiseless patient Spider
Lines: 137
Message-ID: <skk6h7$ovp$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk9ej9$fj9$1@dont-email.me> <jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org>
<skc7a9$698$1@dont-email.me> <skc905$85c$1@dont-email.me>
<skh20o$ji2$1@dont-email.me>
<4fc4f707-2d42-492a-bd41-f791141dbfb2n@googlegroups.com>
<skhjk3$9p4$1@dont-email.me>
<f9db2e75-2ec2-4572-b211-a8b2d6b3e0e6n@googlegroups.com>
<skjkqv$nd3$1@dont-email.me>
<0ba079c3-d672-47b3-b86d-cfc74520ca5dn@googlegroups.com>
<skjshe$2up$1@dont-email.me>
<8af10f0d-80ae-4cf2-b2e1-048a72bef192n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 18 Oct 2021 16:14:31 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="e675145544f77b1e34fd66ac3bfc48ce";
logging-data="25593"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ltYahugGKHiZboHD0KeHJVwb7tS6xB5s="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:DEgKFHLIPFaRmvLrXOAWu00WoAg=
In-Reply-To: <8af10f0d-80ae-4cf2-b2e1-048a72bef192n@googlegroups.com>
Content-Language: en-GB
 by: David Brown - Mon, 18 Oct 2021 16:14 UTC

On 18/10/2021 15:48, Michael S wrote:
> On Monday, October 18, 2021 at 4:24:00 PM UTC+3, David Brown wrote:
>> On 18/10/2021 14:45, Michael S wrote:
>>> On Monday, October 18, 2021 at 2:12:34 PM UTC+3, David Brown wrote:
>>
>>>> Back here in the real world, if programmers stopped writing silly code
>>>> then there would be a lot fewer software problems to go around.
>>>
>>> Don't be silly.
>>> The best solution does not involve magic.
>>> Something like that will do:
>>>
>>> Signed overflow is implementation-defined, but in constrained way.
>>> Possible options are
>>> 1. two-complement wrap-around
>>> 2. trap
>>> 3. saturation
>>> 4. one-complement wrap-around, if there exist a member of committee that care about it
>>> Implementation has to specify the chosen option clearly in documentation. It is allowed to select an option
>>> with special flag. It is not allowed to make option dependent on optimization settings.
>>> If the chosen option is trap and overflow happens in intermediate result of complex expression, but not in the final result than it's it's legal for trap to be intermittent and dependent on ether optimization level or phase of the moon, but not both.
>>>
>> That is not an attitude I would accept in a programmer working for me.
>> (I'd accept - and correct - ignorance. That's a different matter.)
>>
>> I will happily accept a trapping option as a temporary choice while
>> chasing a bug. I will happily accept specific behaviour, coded
>> /correctly/, in cases where specific behaviour is appropriate and
>> correct - in some algorithms, saturation is the desired behaviour, and
>> in a few cases modulo behaviour is the model you want. These can be
>> written correctly in C without any undefined behaviour, special flags,
>
> First, it is true that modulo is what I really want, but I leave other options open.
>

It is rarely a correct answer, except perhaps in a "shoot first, ask
questions later" style of programming.

> Second, I don't think that modulo behavior can be easily achieved in legalistic dialect of C.
> In "solutions" that I had seen there are rat hole near assignment of certain unsigned rvalues
> to signed lvalue and even bigger hole in handling of multiplication.

You use unsigned types - they are defined as modulo.

Yes, there are complications, especially if you have to deal with
unusual targets or write code that works correctly across different
sizes of int. Such code always needs care.

>
> Third, even if it's possible, there are other dimensions apart from legalism.
> One is aesthetic (it's ugly) and other is ergonomic (it's error prone).
>

Relying on wrapping is ugly and error-prone. It encourages people to
write code that makes no logical sense, such as adding two positive
numbers and checking for them being negative. It is error-prone, as it
leads people to think it is safe to take inputs from anywhere and use
them in any old way.

>
>> limited compilers, sacrificing of black cockerels, or whatever other
>> effort you make in order to make incorrect code give the results you want.
>>
>> But anyone who tells me that their own particular interpretation of what
>> happens on signed integer overflow is "the one right answer", "the
>> obvious choice", "the most efficient choice", "what C used to do", or
>> anything on that line - that person is going to have a hard time trying
>> to justify themselves. And if they tell me "it worked when I tried it",
>> I'll know their code reviews will take a lot longer.
>>
>> Coding is, for the most part, a matter of defining and calling functions
>> (as a general term, this includes operators). Every function has a
>> pre-condition that the caller ensures is true before calling the
>> function, and a post-condition that the function ensures is true before
>> returning. The function can - and generally must - assume the
>> pre-condition is true at the start of the function, just as the caller
>> can assume the post-condition is true at the return.
>>
>> Thus if you give the function appropriate inputs, you can expect the
>> desired output. If you give it invalid inputs, you can't have any
>> reasonable expectations about what comes out. Garbage in, garbage out.
>> It is the programmer's job to ensure that he or she does not put
>> garbage in.
>>
>> And in the case of signed integer arithmetic, it is the programmer's job
>> to ensure that the input to expressions will not cause an overflow. It
>> is /not/ the compiler's job to ensure that if garbage is put in, the
>> garbage that comes out should always smell of roses.
>>
>
> From a person that never complains about C Standard definition of "unsigned"
> that sounds more than a bit hypocritical.
>

On what basis do you assume I never complain about C's definition of
unsigned types and arithmetic? I have done so in the past, and no doubt
will do so again - letting your unsigned types wrap is also almost
always a mistake in the code. However, it is /sometimes/ useful to have
modulo behaviour in arithmetic - it's rare, but it happens. And thus it
is good that there is a way to get it in C. The way Ada copes with
this, by separating the concepts of range and modulo behaviour, is IMHO
nicer - there you can make the types you want, signed or unsigned,
modulo or not. But Ada has a more sophisticated type system than C, and
C's choices are a reasonable compromise within a simpler type system.

>>
>> You can argue until you are blue in the face that you think signed
>> integer arithmetic overflow /should/ be defined, whether you have a
>> particular idea for how it should be defined, or you just want it to do
>> "something". There are languages where it /is/ defined. In C, it is
>> /not/ defined. Accept that, or use a different language. End of story.
>
> I am not sure.
> It can be fixed in the future. The pressure is applied all the time and by far more influential people than myself.
>

The pressure is applied regularly, and regularly rejected by people who
are more influential, more experienced, and more knowledgeable than
either of us.

C++20, and now C23, has standardised on two's complement signed integer
representation. If ever there was a time to standardise a particular
type of signed integer overflow, that was the time. The relevant
proposals included such changes - polls were taken, and those parts were
soundly rejected.

A much better solution, IMHO, would be to standardise some pragmas that
let people decide these details themselves. Keep the status quo by
default - signed integer arithmetic has undefined overflow. But have a
standardised pragma that changes this, so that people who want
particular defined behaviour here can have it (just as there are
standardised pragmas for floating point rounding and a few other
floating point bits and pieces).

There could also be standardised versions of gcc's "overflow" builtins,
so that people could write their overflow checks in a sensible,
efficient and portable manner.

Re: Hardware assisted error checking

<NchbJ.5$AR1.0@fx04.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21332&group=comp.arch#21332

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx04.iad.POSTED!not-for-mail
From: ThatWoul...@thevillage.com (EricP)
User-Agent: Thunderbird 2.0.0.24 (Windows/20100228)
MIME-Version: 1.0
Newsgroups: comp.arch
Subject: Re: Hardware assisted error checking
References: <87fstdumxd.fsf@hotmail.com> <sk6s4a$9cm$1@dont-email.me> <1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com> <sk9ej9$fj9$1@dont-email.me> <b230d3fe-324f-491e-9e70-5398f1b68b3cn@googlegroups.com> <sk9n30$nm7$3@newsreader4.netcologne.de> <sk9tq8$ee$1@dont-email.me> <skc5ni$72b$1@dont-email.me> <f492f50e-9268-4bf4-a540-6abae1f693ddn@googlegroups.com> <skcc23$v1v$2@dont-email.me> <5bec3b9f-bdc8-4549-a9f6-b2d4000e9712n@googlegroups.com> <skeani$q5n$1@newsreader4.netcologne.de> <2021Oct16.180742@mips.complang.tuwien.ac.at> <skf3b9$bvc$1@newsreader4.netcologne.de> <it0qviFh5nvU1@mid.individual.net> <jKZaJ.50452$tA2.25596@fx02.iad> <it3fdbF21g9U1@mid.individual.net>
In-Reply-To: <it3fdbF21g9U1@mid.individual.net>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 107
Message-ID: <NchbJ.5$AR1.0@fx04.iad>
X-Complaints-To: abuse@UsenetServer.com
NNTP-Posting-Date: Mon, 18 Oct 2021 16:24:13 UTC
Date: Mon, 18 Oct 2021 12:14:51 -0400
X-Received-Bytes: 4416
 by: EricP - Mon, 18 Oct 2021 16:14 UTC

Niklas Holsti wrote:
> On 2021-10-17 21:14, EricP wrote:
>
>> I tried to compile this on Godbolt but gnat seems to be hardwired
>> that specs go in files with extension "ads" and bodies with "adb"
>> and there is no way to override it.
>
> That is a convention that makes normal ad-hoc use of GNAT very easy,
> compared to earlier Ada compilers which did not use a "source-based
> library" scheme as GNAT does.

Yeah. DEC VAX Ada83 had a code library database and management tool to
track between external file names and internal compiler assigned names.
It worked fine but just adds to the cost of compiler development.

So I understand the desire to avoid that route.

> The convention can be overridden - see chapter 10 in
> https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gnat_ugn.pdf. But Godbolt may
> not let you do that.

None of their options seem to work on Godbolt.

> Here is a single-file version of the program (where I also simplified
> the random initialization a bit). Interestingly, with this version I do
> get a significant slow-down with checks enabled (-gnato) as compared to
> checks suppressed (-gnatp), with about 11% increase in execution time
> when checks are enabled. Perhaps the compiler in-lines code in this
> version since it can see that MM.Do_MM is called only in one place.
>
> $ cat main_mm.adb
>
> with Ada.Numerics.Float_Random;
> with Ada.Real_Time;
> with Ada.Text_IO;
>
> procedure Main_MM
> is
>
> package MM is
>
> type Matrix is array (Positive range <>, Positive range <>) of Float;
>
> procedure Randomize (M : out Matrix);
>
> procedure Do_MM (A, B : in Matrix; C : in out Matrix)
> with Pre =>
> A'First(2) = B'First(1)
> and A'Last (2) = B'Last (1)
> and C'First(1) = A'First(1)
> and C'Last (1) = A'Last (1)
> and C'First(2) = B'First(2)
> and C'Last (2) = B'Last (2);
>
> end MM;
>
> package body MM is
>
> procedure Randomize (M : out Matrix)
> is
> use Ada.Numerics.Float_Random;
> Gen : Generator;
> begin
> Reset (Gen);
> for E of M loop
> E := Random (Gen);
> end loop;
> end Randomize;
>
> procedure Do_MM (A, B : in Matrix; C : in out Matrix)
> is
> begin
> for J in B'Range(2) loop
> for K in A'Range(2) loop
> for I in A'Range(1) loop
> C(I,J) := C(I,J) + A(I,K) * B(K,J);
> end loop;
> end loop;
> end loop;
> end Do_MM;
>
> end MM;
>
> use Ada.Real_Time;
>
> type Matrix_Ref is access MM.Matrix;
>
> A, B, C : Matrix_Ref := new MM.Matrix (1 .. 1000, 1 .. 1000);
>
> T1, T2: Time with Volatile;
>
> begin
>
> MM.Randomize (A.all);
> MM.Randomize (B.all);
> MM.Randomize (C.all);
>
> T1 := Clock;
> MM.Do_MM (A.all, B.all, C.all);
> T2 := Clock;
>
> Ada.Text_IO.Put_Line (Duration'Image (To_Duration (T2 - T1)));
>
> end Main_MM;

This works. Thanks.

Re: Specifying timing constraints was Re: Paper about ISO C

<871r4ip9dm.fsf@hotmail.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21333&group=comp.arch#21333

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!aioe.org!xcrumNapWYKcczN4Ruh1Kw.user.46.165.242.75.POSTED!not-for-mail
From: cla...@hotmail.com
Newsgroups: comp.arch
Subject: Re: Specifying timing constraints was Re: Paper about ISO C
Date: Mon, 18 Oct 2021 19:48:05 +0300
Organization: Aioe.org NNTP Server
Message-ID: <871r4ip9dm.fsf@hotmail.com>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk9ej9$fj9$1@dont-email.me>
<jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org>
<skc7a9$698$1@dont-email.me> <skc905$85c$1@dont-email.me>
<skh20o$ji2$1@dont-email.me>
<4fc4f707-2d42-492a-bd41-f791141dbfb2n@googlegroups.com>
<skhjk3$9p4$1@dont-email.me>
<f9db2e75-2ec2-4572-b211-a8b2d6b3e0e6n@googlegroups.com>
<skjkqv$nd3$1@dont-email.me>
<0ba079c3-d672-47b3-b86d-cfc74520ca5dn@googlegroups.com>
<875ytupjzd.fsf@hotmail.com> <skk5h9$gth$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="17034"; posting-host="xcrumNapWYKcczN4Ruh1Kw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:J8Hm5Kg3XS8JgujPnaRnA77yXLk=
 by: cla...@hotmail.com - Mon, 18 Oct 2021 16:48 UTC

David Brown <david.brown@hesbynett.no> writes:

> On 18/10/2021 14:59, clamky@hotmail.com wrote:
>> Michael S <already5chosen@yahoo.com> writes:
>>
>>> On Monday, October 18, 2021 at 2:12:34 PM UTC+3, David Brown wrote:
>>>> On 18/10/2021 01:47, Victor Yodaiken wrote:
>>>>> On Sunday, October 17, 2021 at 11:39:37 AM UTC-5, David Brown wrote:
>>>>>> On 17/10/2021 16:40, Victor Yodaiken wrote:
>>>>>>> On Sunday, October 17, 2021 at 6:39:07 AM UTC-5, David Brown wrote:
>>>>>>>
>>
>> [..]
>>
>>>> Back here in the real world, if programmers stopped writing silly code
>>>> then there would be a lot fewer software problems to go around.
>>>
>>> Don't be silly.
>>> The best solution does not involve magic.
>>> Something like that will do:
>>>
>>> Signed overflow is implementation-defined, but in constrained way.
>>
>> I think that is what standard calls "unspecified behavior"
>
> No, "unspecified behaviour" is entirely different.
>
> Signed overflow is covered in 6.5p5:
>
> """
> If an exceptional condition occurs during the evaluation of an
> expression (that is, if the result is not mathematically defined or not
> in the range of representable values for its type), the behavior is
> undefined.
> """
>
> "Unspecified behaviour" could mean (for example) that adding two ints
> would always give you a valid int - it's just that you would not know
> /which/ int you get if you had an overflow.

3.4.4
1
unspecified behavior
use of an unspecified value, or other behavior where this International Standard provides two or
more possibilities and imposes no further requirements on which is chosen in any instance
2
EXAMPLE An example of unspecified behavior is the order in which the
arguments to a function are evaluated.

Michael S provided four variants that are "acceptable" hence an attemt
at humor with "unspecified squared". You know you have failed when the
joke has to be explained.

>
> "Unspecified" is used for things like the order of evaluation for "a +
> b" - it is unspecified which is evaluated first. (That means the
> compiler doesn't need to document it - it doesn't even need to be
> consistent from run to run.)

Re: Specifying timing constraints was Re: Paper about ISO C

<87wnmanujt.fsf@hotmail.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21334&group=comp.arch#21334

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!aioe.org!xcrumNapWYKcczN4Ruh1Kw.user.46.165.242.75.POSTED!not-for-mail
From: cla...@hotmail.com
Newsgroups: comp.arch
Subject: Re: Specifying timing constraints was Re: Paper about ISO C
Date: Mon, 18 Oct 2021 19:53:42 +0300
Organization: Aioe.org NNTP Server
Message-ID: <87wnmanujt.fsf@hotmail.com>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk9ej9$fj9$1@dont-email.me>
<jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org>
<skc7a9$698$1@dont-email.me> <skc905$85c$1@dont-email.me>
<skh20o$ji2$1@dont-email.me>
<4fc4f707-2d42-492a-bd41-f791141dbfb2n@googlegroups.com>
<skhjk3$9p4$1@dont-email.me>
<f9db2e75-2ec2-4572-b211-a8b2d6b3e0e6n@googlegroups.com>
<skjkqv$nd3$1@dont-email.me>
<0ba079c3-d672-47b3-b86d-cfc74520ca5dn@googlegroups.com>
<875ytupjzd.fsf@hotmail.com> <skk5h9$gth$1@dont-email.me>
<871r4ip9dm.fsf@hotmail.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="22284"; posting-host="xcrumNapWYKcczN4Ruh1Kw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
Cancel-Lock: sha1:IjScHHZzmFZH4WRPl13eGp0VD5g=
X-Notice: Filtered by postfilter v. 0.9.2
 by: cla...@hotmail.com - Mon, 18 Oct 2021 16:53 UTC

clamky@hotmail.com writes:

> David Brown <david.brown@hesbynett.no> writes:
>
>> On 18/10/2021 14:59, clamky@hotmail.com wrote:
>>> Michael S <already5chosen@yahoo.com> writes:
>>>
>>>> On Monday, October 18, 2021 at 2:12:34 PM UTC+3, David Brown wrote:
>>>>> On 18/10/2021 01:47, Victor Yodaiken wrote:
>>>>>> On Sunday, October 17, 2021 at 11:39:37 AM UTC-5, David Brown wrote:
>>>>>>> On 17/10/2021 16:40, Victor Yodaiken wrote:
>>>>>>>> On Sunday, October 17, 2021 at 6:39:07 AM UTC-5, David Brown wrote:
>>>>>>>>
[..]

>
> 3.4.4
> 1
> unspecified behavior
> use of an unspecified value, or other behavior where this
> International Standard provides two or
> more possibilities and imposes no further requirements on which is
> chosen in any instance
> 2
> EXAMPLE An example of unspecified behavior is the order in which the
> arguments to a function are evaluated.
>

[..]

And only now "... or more ..." really registered, i plead temporal
insanity. Sorry i was wrong. Guess this is a prime example of an ald
adage's:
Programmers are simpletons - they count one, two, many...

Re: Specifying timing constraints was Re: Paper about ISO C

<4fc7ef31-0248-4cff-a63f-cb8d00169f72n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21335&group=comp.arch#21335

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ad4:4f43:: with SMTP id eu3mr26797063qvb.44.1634576426553;
Mon, 18 Oct 2021 10:00:26 -0700 (PDT)
X-Received: by 2002:a54:4e86:: with SMTP id c6mr60445oiy.84.1634576426259;
Mon, 18 Oct 2021 10:00:26 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Mon, 18 Oct 2021 10:00:26 -0700 (PDT)
In-Reply-To: <skk6h7$ovp$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=24.173.181.154; posting-account=jn4_9AoAAADlg7v8KtkkjWBduIrvz8VB
NNTP-Posting-Host: 24.173.181.154
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com> <3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me> <1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk9ej9$fj9$1@dont-email.me> <jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org>
<skc7a9$698$1@dont-email.me> <skc905$85c$1@dont-email.me> <skh20o$ji2$1@dont-email.me>
<4fc4f707-2d42-492a-bd41-f791141dbfb2n@googlegroups.com> <skhjk3$9p4$1@dont-email.me>
<f9db2e75-2ec2-4572-b211-a8b2d6b3e0e6n@googlegroups.com> <skjkqv$nd3$1@dont-email.me>
<0ba079c3-d672-47b3-b86d-cfc74520ca5dn@googlegroups.com> <skjshe$2up$1@dont-email.me>
<8af10f0d-80ae-4cf2-b2e1-048a72bef192n@googlegroups.com> <skk6h7$ovp$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4fc7ef31-0248-4cff-a63f-cb8d00169f72n@googlegroups.com>
Subject: Re: Specifying timing constraints was Re: Paper about ISO C
From: victor.y...@gmail.com (Victor Yodaiken)
Injection-Date: Mon, 18 Oct 2021 17:00:26 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 14
 by: Victor Yodaiken - Mon, 18 Oct 2021 17:00 UTC

On Monday, October 18, 2021 at 11:14:33 AM UTC-5, David Brown wrote:

> Relying on wrapping is ugly and error-prone. It encourages people to
> write code that makes no logical sense, such as adding two positive
> numbers and checking for them being negative.

1. Signed arithmetic is a representation of arithmetic in the residue ring of the integers mod 2^{k}
2. Signed arithmetic is a patchy approximation of arithmetic over the integers with known failure cases and
unpredictable results and where the implication of x+1 > x and x <= INT_MAX is that INT_MAX < INT_MAX

Of course 1 makes no logical sense. Bravo!

Re: Specifying timing constraints was Re: Paper about ISO C

<skkc39$ubi$2@newsreader4.netcologne.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21336&group=comp.arch#21336

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!rocksolid2!news.neodome.net!2.eu.feeder.erje.net!feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-3308-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch
Subject: Re: Specifying timing constraints was Re: Paper about ISO C
Date: Mon, 18 Oct 2021 17:49:29 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <skkc39$ubi$2@newsreader4.netcologne.de>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk9ej9$fj9$1@dont-email.me> <jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org>
<skc7a9$698$1@dont-email.me> <skc905$85c$1@dont-email.me>
<skh20o$ji2$1@dont-email.me>
<4fc4f707-2d42-492a-bd41-f791141dbfb2n@googlegroups.com>
<skhjk3$9p4$1@dont-email.me>
<f9db2e75-2ec2-4572-b211-a8b2d6b3e0e6n@googlegroups.com>
<skjkqv$nd3$1@dont-email.me>
<0ba079c3-d672-47b3-b86d-cfc74520ca5dn@googlegroups.com>
<skjshe$2up$1@dont-email.me>
<8af10f0d-80ae-4cf2-b2e1-048a72bef192n@googlegroups.com>
<skk6h7$ovp$1@dont-email.me>
<4fc7ef31-0248-4cff-a63f-cb8d00169f72n@googlegroups.com>
Injection-Date: Mon, 18 Oct 2021 17:49:29 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-3308-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:3308:0:7285:c2ff:fe6c:992d";
logging-data="31090"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Mon, 18 Oct 2021 17:49 UTC

Victor Yodaiken <victor.yodaiken@gmail.com> schrieb:
> On Monday, October 18, 2021 at 11:14:33 AM UTC-5, David Brown wrote:
>
>> Relying on wrapping is ugly and error-prone. It encourages people to
>> write code that makes no logical sense, such as adding two positive
>> numbers and checking for them being negative.
>

It seems that reminding you about USENET line breaking conventions
has little effect. I am beginning to suspect that this is rather
typical of you, it is certainly in line with your other attitudes.

I've inserted the line breaks for you (again).

> 1. Signed arithmetic is a representation of arithmetic in the
> residue ring of the integers mod 2^{k}

So, -1 is larger than 1 for signed integers?

Re: Specifying timing constraints was Re: Paper about ISO C

<cb406117-6bc6-4ccd-a228-0591187378fdn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21337&group=comp.arch#21337

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:620a:231:: with SMTP id u17mr24172642qkm.237.1634580211958;
Mon, 18 Oct 2021 11:03:31 -0700 (PDT)
X-Received: by 2002:a9d:189:: with SMTP id e9mr1072548ote.243.1634580210563;
Mon, 18 Oct 2021 11:03:30 -0700 (PDT)
Path: i2pn2.org!rocksolid2!news.neodome.net!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Mon, 18 Oct 2021 11:03:30 -0700 (PDT)
In-Reply-To: <skkc39$ubi$2@newsreader4.netcologne.de>
Injection-Info: google-groups.googlegroups.com; posting-host=24.173.181.154; posting-account=jn4_9AoAAADlg7v8KtkkjWBduIrvz8VB
NNTP-Posting-Host: 24.173.181.154
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com> <3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me> <1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk9ej9$fj9$1@dont-email.me> <jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org>
<skc7a9$698$1@dont-email.me> <skc905$85c$1@dont-email.me> <skh20o$ji2$1@dont-email.me>
<4fc4f707-2d42-492a-bd41-f791141dbfb2n@googlegroups.com> <skhjk3$9p4$1@dont-email.me>
<f9db2e75-2ec2-4572-b211-a8b2d6b3e0e6n@googlegroups.com> <skjkqv$nd3$1@dont-email.me>
<0ba079c3-d672-47b3-b86d-cfc74520ca5dn@googlegroups.com> <skjshe$2up$1@dont-email.me>
<8af10f0d-80ae-4cf2-b2e1-048a72bef192n@googlegroups.com> <skk6h7$ovp$1@dont-email.me>
<4fc7ef31-0248-4cff-a63f-cb8d00169f72n@googlegroups.com> <skkc39$ubi$2@newsreader4.netcologne.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <cb406117-6bc6-4ccd-a228-0591187378fdn@googlegroups.com>
Subject: Re: Specifying timing constraints was Re: Paper about ISO C
From: victor.y...@gmail.com (Victor Yodaiken)
Injection-Date: Mon, 18 Oct 2021 18:03:31 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 28
 by: Victor Yodaiken - Mon, 18 Oct 2021 18:03 UTC

On Monday, October 18, 2021 at 12:49:31 PM UTC-5, Thomas Koenig wrote:
> Victor Yodaiken <victor....@gmail.com> schrieb:
> > On Monday, October 18, 2021 at 11:14:33 AM UTC-5, David Brown wrote:
> >
> >> Relying on wrapping is ugly and error-prone. It encourages people to
> >> write code that makes no logical sense, such as adding two positive
> >> numbers and checking for them being negative.
> >
> It seems that reminding you about USENET line breaking conventions
> has little effect. I am beginning to suspect that this is rather
> typical of you, it is certainly in line with your other attitudes.
>
and i am not even embarrassed

> I've inserted the line breaks for you (again).
> > 1. Signed arithmetic is a representation of arithmetic in the
> > residue ring of the integers mod 2^{k}
> So, -1 is larger than 1 for signed integers?

There is no < relation in Z/2^kZ. The comparison is between the selected class
representatives INT_MIN ... INT_MAX
so INT_MAX+1 < INT_MAX which is a consequence both of the ring
structure and the operation of 2s complement arithmetic,
and x+1 > x is NOT a theorem. This model (a) is mathematically
consistent and (b) represents how 99% of modern processor architectures
do signed arithmetic.

Re: Specifying timing constraints was Re: Paper about ISO C

<29c75008-3351-4e41-9d99-2f294f8eff3en@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21339&group=comp.arch#21339

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ac8:4111:: with SMTP id q17mr32502185qtl.407.1634585867199;
Mon, 18 Oct 2021 12:37:47 -0700 (PDT)
X-Received: by 2002:a9d:189:: with SMTP id e9mr1444955ote.243.1634585866954;
Mon, 18 Oct 2021 12:37:46 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Mon, 18 Oct 2021 12:37:46 -0700 (PDT)
In-Reply-To: <86a6j6l8ci.fsf@linuxsc.com>
Injection-Info: google-groups.googlegroups.com; posting-host=87.68.182.153; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 87.68.182.153
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com> <3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me> <1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk9ej9$fj9$1@dont-email.me> <jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org>
<skc7a9$698$1@dont-email.me> <skc905$85c$1@dont-email.me> <skh20o$ji2$1@dont-email.me>
<4fc4f707-2d42-492a-bd41-f791141dbfb2n@googlegroups.com> <skhjk3$9p4$1@dont-email.me>
<f9db2e75-2ec2-4572-b211-a8b2d6b3e0e6n@googlegroups.com> <skjkqv$nd3$1@dont-email.me>
<0ba079c3-d672-47b3-b86d-cfc74520ca5dn@googlegroups.com> <86a6j6l8ci.fsf@linuxsc.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <29c75008-3351-4e41-9d99-2f294f8eff3en@googlegroups.com>
Subject: Re: Specifying timing constraints was Re: Paper about ISO C
From: already5...@yahoo.com (Michael S)
Injection-Date: Mon, 18 Oct 2021 19:37:47 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Michael S - Mon, 18 Oct 2021 19:37 UTC

On Monday, October 18, 2021 at 5:24:02 PM UTC+3, Tim Rentsch wrote:
> Michael S <already...@yahoo.com> writes:
>
> >> [..sarcastic comments regarding signed overflow..]
> > Don't be silly.
> > The best solution does not involve magic.
> > Something like that will do:
> >
> > Signed overflow is implementation-defined, but in constrained way.
> > Possible options are
> > 1. two-complement wrap-around
> > 2. trap
> > 3. saturation
> > 4. one-complement wrap-around, if there exist a member of
> > committee that care about it
> >
> > Implementation has to specify the chosen option clearly in
> > documentation. It is allowed to select an option with special
> > flag. It is not allowed to make option dependent on optimization
> > settings. If the chosen option is trap and overflow happens in
> > intermediate result of complex expression, but not in the final
> > result than it's it's legal for trap to be intermittent and
> > dependent on ether optimization level or phase of the moon, but
> > not both.
> My sense is this idea is not much better than how things are
> now. I would like to see the decision be under control of
> the source code, perhaps by means of a #pragma:
>
> #pragma STDC SIGNED_OVERFLOW WRAP
> #pragma STDC SIGNED_OVERFLOW TRAP
> #pragma STDC SIGNED_OVERFLOW SATURATE
> #pragma STDC SIGNED_OVERFLOW UNDEFINED
> (..others?..)
>
> If it's important, implementations might be allowed not to
> implement some or all of these choices; but if they don't then
> they must at least check the #pragma line for legality and fail
> the compilation if they cannot accommodate the choice indicated
> (or if the #pragma STDC doesn't scan for some reason).

I'd very much prefer if UNDEFINED is not in the list of Standard compliant options.
Compiler can offer it, but then it would have no right to identify as "standard C".
IMHO, UNDEFINED is only good to win specifically crafted benchmarks.

I agree with the rest of your suggestions.

Re: Specifying timing constraints was Re: Paper about ISO C

<LClbJ.602$xjIc.241@fx01.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21341&group=comp.arch#21341

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx01.iad.POSTED!not-for-mail
From: ThatWoul...@thevillage.com (EricP)
User-Agent: Thunderbird 2.0.0.24 (Windows/20100228)
MIME-Version: 1.0
Newsgroups: comp.arch
Subject: Re: Specifying timing constraints was Re: Paper about ISO C
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me> <afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com> <3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com> <sk6s4a$9cm$1@dont-email.me> <1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com> <sk9ej9$fj9$1@dont-email.me> <jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org> <skc7a9$698$1@dont-email.me> <skc905$85c$1@dont-email.me> <skh20o$ji2$1@dont-email.me> <4fc4f707-2d42-492a-bd41-f791141dbfb2n@googlegroups.com> <skhjk3$9p4$1@dont-email.me> <f9db2e75-2ec2-4572-b211-a8b2d6b3e0e6n@googlegroups.com> <skjkqv$nd3$1@dont-email.me> <0ba079c3-d672-47b3-b86d-cfc74520ca5dn@googlegroups.com> <86a6j6l8ci.fsf@linuxsc.com>
In-Reply-To: <86a6j6l8ci.fsf@linuxsc.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 82
Message-ID: <LClbJ.602$xjIc.241@fx01.iad>
X-Complaints-To: abuse@UsenetServer.com
NNTP-Posting-Date: Mon, 18 Oct 2021 21:24:59 UTC
Date: Mon, 18 Oct 2021 17:23:18 -0400
X-Received-Bytes: 4671
X-Original-Bytes: 4620
 by: EricP - Mon, 18 Oct 2021 21:23 UTC

Tim Rentsch wrote:
> Michael S <already5chosen@yahoo.com> writes:
>
>>> [..sarcastic comments regarding signed overflow..]
>
>> Don't be silly.
>> The best solution does not involve magic.
>> Something like that will do:
>>
>> Signed overflow is implementation-defined, but in constrained way.
>> Possible options are
>> 1. two-complement wrap-around
>> 2. trap
>> 3. saturation
>> 4. one-complement wrap-around, if there exist a member of
>> committee that care about it
>>
>> Implementation has to specify the chosen option clearly in
>> documentation. It is allowed to select an option with special
>> flag. It is not allowed to make option dependent on optimization
>> settings. If the chosen option is trap and overflow happens in
>> intermediate result of complex expression, but not in the final
>> result than it's it's legal for trap to be intermittent and
>> dependent on ether optimization level or phase of the moon, but
>> not both.
>
> My sense is this idea is not much better than how things are
> now. I would like to see the decision be under control of
> the source code, perhaps by means of a #pragma:
>
> #pragma STDC SIGNED_OVERFLOW WRAP
> #pragma STDC SIGNED_OVERFLOW TRAP
> #pragma STDC SIGNED_OVERFLOW SATURATE
> #pragma STDC SIGNED_OVERFLOW UNDEFINED
> (..others?..)
>
> If it's important, implementations might be allowed not to
> implement some or all of these choices; but if they don't then
> they must at least check the #pragma line for legality and fail
> the compilation if they cannot accommodate the choice indicated
> (or if the #pragma STDC doesn't scan for some reason).

Gcc C already has the compiler switch -ftrapv to enable signed integer
overflow checks (operators are implemented as subroutine calls).

The problem with such pragmas in C is the same as compiler switches:
they cause many false positives (overflow traps) because they are too
much of a blunt object. As a consequence people just turn them off.

A number of studies of real world code have shown that it is a
mixture of signed and unsigned, checked and unchecked assumptions
*often within a single expression*.

E.g. these folks tap into clang's front end to inject checks into code.

Understanding Integer Overflow in C/C++, 2015
https://wdtz.org/files/tosem15.pdf

Consider a hypothetical line from a codec:

signal = signal + impulse[i + j];

In this expression, i+j are signed integers and should be added using
checked arithmetic, the array index then checked against array bounds,
the array element address addition calculated using unsigned modulo
arithmetic, and signal value added using saturating arithmetic.

Note also that some unsigned wrap arounds are bugs, some not.
It depends on the programmers intent.

This is why the VAX with it PSW global flag enabling overflow detect
had problems - real code would have to keep switching it on and off,
which would cause a large overhead so they just left it on for
Fortran or Ada and lived with occasional false overflow traps.
Which is why Alpha has separate instructions for Add and AddTrapOverflow.

The only mechanism I can think of that can handle that kind of
flexibility smoothly would be based on multiple language data types,
and an ISA with separate instructions for each operation on each type.

Re: Specifying timing constraints was Re: Paper about ISO C

<skl12c$i1n$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21342&group=comp.arch#21342

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: iva...@millcomputing.com (Ivan Godard)
Newsgroups: comp.arch
Subject: Re: Specifying timing constraints was Re: Paper about ISO C
Date: Mon, 18 Oct 2021 16:47:24 -0700
Organization: A noiseless patient Spider
Lines: 90
Message-ID: <skl12c$i1n$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk9ej9$fj9$1@dont-email.me> <jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org>
<skc7a9$698$1@dont-email.me> <skc905$85c$1@dont-email.me>
<skh20o$ji2$1@dont-email.me>
<4fc4f707-2d42-492a-bd41-f791141dbfb2n@googlegroups.com>
<skhjk3$9p4$1@dont-email.me>
<f9db2e75-2ec2-4572-b211-a8b2d6b3e0e6n@googlegroups.com>
<skjkqv$nd3$1@dont-email.me>
<0ba079c3-d672-47b3-b86d-cfc74520ca5dn@googlegroups.com>
<86a6j6l8ci.fsf@linuxsc.com> <LClbJ.602$xjIc.241@fx01.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 18 Oct 2021 23:47:25 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f8922af8a4b36a995c0eee986127cdaf";
logging-data="18487"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19lzSMAGB394ayi5yCHFYwQ"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.2.0
Cancel-Lock: sha1:Ug6NQ7gy7k906rrKvqxfQXy6ED8=
In-Reply-To: <LClbJ.602$xjIc.241@fx01.iad>
Content-Language: en-US
 by: Ivan Godard - Mon, 18 Oct 2021 23:47 UTC

On 10/18/2021 2:23 PM, EricP wrote:
> Tim Rentsch wrote:
>> Michael S <already5chosen@yahoo.com> writes:
>>
>>>> [..sarcastic comments regarding signed overflow..]
>>
>>> Don't be silly.
>>> The best solution does not involve magic.
>>> Something like that will do:
>>>
>>> Signed overflow is implementation-defined, but in constrained way.
>>> Possible options are
>>> 1. two-complement wrap-around
>>> 2. trap
>>> 3. saturation
>>> 4. one-complement wrap-around, if there exist a member of
>>>    committee that care about it
>>>
>>> Implementation has to specify the chosen option clearly in
>>> documentation.  It is allowed to select an option with special
>>> flag.  It is not allowed to make option dependent on optimization
>>> settings.  If the chosen option is trap and overflow happens in
>>> intermediate result of complex expression, but not in the final
>>> result than it's it's legal for trap to be intermittent and
>>> dependent on ether optimization level or phase of the moon, but
>>> not both.
>>
>> My sense is this idea is not much better than how things are
>> now.  I would like to see the decision be under control of
>> the source code, perhaps by means of a #pragma:
>>
>>     #pragma STDC SIGNED_OVERFLOW WRAP
>>     #pragma STDC SIGNED_OVERFLOW TRAP
>>     #pragma STDC SIGNED_OVERFLOW SATURATE
>>     #pragma STDC SIGNED_OVERFLOW UNDEFINED
>>     (..others?..)
>>
>> If it's important, implementations might be allowed not to
>> implement some or all of these choices;  but if they don't then
>> they must at least check the #pragma line for legality and fail
>> the compilation if they cannot accommodate the choice indicated
>> (or if the #pragma STDC doesn't scan for some reason).
>
> Gcc C already has the compiler switch -ftrapv to enable signed integer
> overflow checks (operators are implemented as subroutine calls).
>
> The problem with such pragmas in C is the same as compiler switches:
> they cause many false positives (overflow traps) because they are too
> much of a blunt object. As a consequence people just turn them off.
>
> A number of studies of real world code have shown that it is a
> mixture of signed and unsigned, checked and unchecked assumptions
> *often within a single expression*.
>
> E.g. these folks tap into clang's front end to inject checks into code.
>
> Understanding Integer Overflow in C/C++, 2015
> https://wdtz.org/files/tosem15.pdf
>
> Consider a hypothetical line from a codec:
>
>   signal = signal + impulse[i + j];
>
> In this expression, i+j are signed integers and should be added using
> checked arithmetic, the array index then checked against array bounds,
> the array element address addition calculated using unsigned modulo
> arithmetic, and signal value added using saturating arithmetic.
>
> Note also that some unsigned wrap arounds are bugs, some not.
> It depends on the programmers intent.
>
> This is why the VAX with it PSW global flag enabling overflow detect
> had problems - real code would have to keep switching it on and off,
> which would cause a large overhead so they just left it on for
> Fortran or Ada and lived with occasional false overflow traps.
> Which is why Alpha has separate instructions for Add and AddTrapOverflow.
>
> The only mechanism I can think of that can handle that kind of
> flexibility smoothly would be based on multiple language data types,
> and an ISA with separate instructions for each operation on each type.

As for example:
enumWithTraits(intNumEnums, overflowCode,
excepting,
modulo,
saturating,
widening
);
available in every kind of operation that can overflow?

Re: Specifying timing constraints was Re: Paper about ISO C

<skllj9$qel$1@newsreader4.netcologne.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21343&group=comp.arch#21343

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-3308-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch
Subject: Re: Specifying timing constraints was Re: Paper about ISO C
Date: Tue, 19 Oct 2021 05:37:45 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <skllj9$qel$1@newsreader4.netcologne.de>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk9ej9$fj9$1@dont-email.me> <jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org>
<skc7a9$698$1@dont-email.me> <skc905$85c$1@dont-email.me>
<skh20o$ji2$1@dont-email.me>
<4fc4f707-2d42-492a-bd41-f791141dbfb2n@googlegroups.com>
<skhjk3$9p4$1@dont-email.me>
<f9db2e75-2ec2-4572-b211-a8b2d6b3e0e6n@googlegroups.com>
<skjkqv$nd3$1@dont-email.me>
<0ba079c3-d672-47b3-b86d-cfc74520ca5dn@googlegroups.com>
<skjshe$2up$1@dont-email.me>
<8af10f0d-80ae-4cf2-b2e1-048a72bef192n@googlegroups.com>
<skk6h7$ovp$1@dont-email.me>
<4fc7ef31-0248-4cff-a63f-cb8d00169f72n@googlegroups.com>
<skkc39$ubi$2@newsreader4.netcologne.de>
<cb406117-6bc6-4ccd-a228-0591187378fdn@googlegroups.com>
Injection-Date: Tue, 19 Oct 2021 05:37:45 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-3308-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:3308:0:7285:c2ff:fe6c:992d";
logging-data="27093"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Tue, 19 Oct 2021 05:37 UTC

Victor Yodaiken <victor.yodaiken@gmail.com> schrieb:
> On Monday, October 18, 2021 at 12:49:31 PM UTC-5, Thomas Koenig wrote:
>> Victor Yodaiken <victor....@gmail.com> schrieb:
>> > On Monday, October 18, 2021 at 11:14:33 AM UTC-5, David Brown wrote:
>> >
>> >> Relying on wrapping is ugly and error-prone. It encourages people to
>> >> write code that makes no logical sense, such as adding two positive
>> >> numbers and checking for them being negative.
>> >
>> It seems that reminding you about USENET line breaking conventions
>> has little effect. I am beginning to suspect that this is rather
>> typical of you, it is certainly in line with your other attitudes.
>>
> and i am not even embarrassed

A piece of advice, then. Not following the rules in a forum like
that will lead to people discarding your opinions out of hand,
they will start with the assumption that you are wrong; they
will only skip your arguments instead of taking them seriously.

If you are trying to convince anybody, that is not an effective
way to do it. If you are not trying to convince anybody, but
rather would like to stir up discussion for the sake of discussion,
then you're on the right track.

>
>> I've inserted the line breaks for you (again).
>> > 1. Signed arithmetic is a representation of arithmetic in the
>> > residue ring of the integers mod 2^{k}
>> So, -1 is larger than 1 for signed integers?
>
> There is no < relation in Z/2^kZ.

So it seems you are proposing to ban the "<" operator in C.
Excellent move.

Re: Specifying timing constraints was Re: Paper about ISO C

<865yttldcu.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21344&group=comp.arch#21344

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.arch
Subject: Re: Specifying timing constraints was Re: Paper about ISO C
Date: Mon, 18 Oct 2021 23:48:01 -0700
Organization: A noiseless patient Spider
Lines: 63
Message-ID: <865yttldcu.fsf@linuxsc.com>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me> <afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com> <3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com> <sk6s4a$9cm$1@dont-email.me> <1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com> <sk9ej9$fj9$1@dont-email.me> <jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org> <skc7a9$698$1@dont-email.me> <skc905$85c$1@dont-email.me> <skh20o$ji2$1@dont-email.me> <4fc4f707-2d42-492a-bd41-f791141dbfb2n@googlegroups.com> <skhjk3$9p4$1@dont-email.me> <f9db2e75-2ec2-4572-b211-a8b2d6b3e0e6n@googlegroups.com> <skjkqv$nd3$1@dont-email.me> <0ba079c3-d672-47b3-b86d-cfc74520ca5dn@googlegroups.com> <86a6j6l8ci.fsf@linuxsc.com> <29c75008-3351-4e41-9d99-2f294f8eff3en@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="98692b60ba984751800274a3a07b6a9f";
logging-data="26861"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1//Ga/Hf47Nfcd6Z62Zrj1VpT+/zG2CpuI="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:qMULVRBtw1eiTYkFswlDWE/QHUs=
sha1:cfj/1feAkwS6E9tZJtDTz4Lh9RQ=
 by: Tim Rentsch - Tue, 19 Oct 2021 06:48 UTC

Michael S <already5chosen@yahoo.com> writes:

> On Monday, October 18, 2021 at 5:24:02 PM UTC+3, Tim Rentsch wrote:
>
>> Michael S <already...@yahoo.com> writes:
>>
>>>> [..sarcastic comments regarding signed overflow..]
>>>
>>> Don't be silly.
>>> The best solution does not involve magic.
>>> Something like that will do:
>>>
>>> Signed overflow is implementation-defined, but in constrained way.
>>> Possible options are
>>> 1. two-complement wrap-around
>>> 2. trap
>>> 3. saturation
>>> 4. one-complement wrap-around, if there exist a member of
>>> committee that care about it
>>>
>>> Implementation has to specify the chosen option clearly in
>>> documentation. It is allowed to select an option with special
>>> flag. It is not allowed to make option dependent on optimization
>>> settings. If the chosen option is trap and overflow happens in
>>> intermediate result of complex expression, but not in the final
>>> result than it's it's legal for trap to be intermittent and
>>> dependent on ether optimization level or phase of the moon, but
>>> not both.
>>
>> My sense is this idea is not much better than how things are
>> now. I would like to see the decision be under control of
>> the source code, perhaps by means of a #pragma:
>>
>> #pragma STDC SIGNED_OVERFLOW WRAP
>> #pragma STDC SIGNED_OVERFLOW TRAP
>> #pragma STDC SIGNED_OVERFLOW SATURATE
>> #pragma STDC SIGNED_OVERFLOW UNDEFINED
>> (..others?..)
>>
>> If it's important, implementations might be allowed not to
>> implement some or all of these choices; but if they don't then
>> they must at least check the #pragma line for legality and fail
>> the compilation if they cannot accommodate the choice indicated
>> (or if the #pragma STDC doesn't scan for some reason).
>
> I'd very much prefer if UNDEFINED is not in the list of Standard
> compliant options. Compiler can offer it, but then it would have
> no right to identify as "standard C". IMHO, UNDEFINED is only
> good to win specifically crafted benchmarks.

I think it's necessary to have the option, to allow compatibility
with earlier versions of the C standard, and if the option is
possible there should be a way of explicitly selecting it. I very
much doubt I would ever select it myself, but at the same time I
think it's wrong to exclude it just because I personally don't like
it. And if there is someone who wants to make that choice, I would
much rather it be among the set of officially recognized features
than that it be some non-standard option or attribute or something
along those lines.

> I agree with the rest of your suggestions.

Agreement? I'm speechless. :)

Re: Specifying timing constraints was Re: Paper about ISO C

<sklpvn$qt0$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21345&group=comp.arch#21345

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.arch
Subject: Re: Specifying timing constraints was Re: Paper about ISO C
Date: Tue, 19 Oct 2021 08:52:38 +0200
Organization: A noiseless patient Spider
Lines: 67
Message-ID: <sklpvn$qt0$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk9ej9$fj9$1@dont-email.me> <jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org>
<skc7a9$698$1@dont-email.me> <skc905$85c$1@dont-email.me>
<skh20o$ji2$1@dont-email.me>
<4fc4f707-2d42-492a-bd41-f791141dbfb2n@googlegroups.com>
<skhjk3$9p4$1@dont-email.me>
<f9db2e75-2ec2-4572-b211-a8b2d6b3e0e6n@googlegroups.com>
<skjkqv$nd3$1@dont-email.me>
<0ba079c3-d672-47b3-b86d-cfc74520ca5dn@googlegroups.com>
<875ytupjzd.fsf@hotmail.com> <skk5h9$gth$1@dont-email.me>
<871r4ip9dm.fsf@hotmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 19 Oct 2021 06:52:39 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="8bc4cebc62c475127dc1ae785648adc4";
logging-data="27552"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX195qvg1lwqmfPDgbnSK/4mtOKbNvCcd0Us="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:rflpsBPWsd5JBMb2eJxpBshcMTo=
In-Reply-To: <871r4ip9dm.fsf@hotmail.com>
Content-Language: en-GB
 by: David Brown - Tue, 19 Oct 2021 06:52 UTC

On 18/10/2021 18:48, clamky@hotmail.com wrote:
> David Brown <david.brown@hesbynett.no> writes:
>
>> On 18/10/2021 14:59, clamky@hotmail.com wrote:
>>> Michael S <already5chosen@yahoo.com> writes:
>>>
>>>> On Monday, October 18, 2021 at 2:12:34 PM UTC+3, David Brown wrote:
>>>>> On 18/10/2021 01:47, Victor Yodaiken wrote:
>>>>>> On Sunday, October 17, 2021 at 11:39:37 AM UTC-5, David Brown wrote:
>>>>>>> On 17/10/2021 16:40, Victor Yodaiken wrote:
>>>>>>>> On Sunday, October 17, 2021 at 6:39:07 AM UTC-5, David Brown wrote:
>>>>>>>>
>>>
>>> [..]
>>>
>>>>> Back here in the real world, if programmers stopped writing silly code
>>>>> then there would be a lot fewer software problems to go around.
>>>>
>>>> Don't be silly.
>>>> The best solution does not involve magic.
>>>> Something like that will do:
>>>>
>>>> Signed overflow is implementation-defined, but in constrained way.
>>>
>>> I think that is what standard calls "unspecified behavior"
>>
>> No, "unspecified behaviour" is entirely different.
>>
>> Signed overflow is covered in 6.5p5:
>>
>> """
>> If an exceptional condition occurs during the evaluation of an
>> expression (that is, if the result is not mathematically defined or not
>> in the range of representable values for its type), the behavior is
>> undefined.
>> """
>>
>> "Unspecified behaviour" could mean (for example) that adding two ints
>> would always give you a valid int - it's just that you would not know
>> /which/ int you get if you had an overflow.
>
> 3.4.4
> 1
> unspecified behavior
> use of an unspecified value, or other behavior where this International Standard provides two or
> more possibilities and imposes no further requirements on which is chosen in any instance
> 2
> EXAMPLE An example of unspecified behavior is the order in which the
> arguments to a function are evaluated.
>
> Michael S provided four variants that are "acceptable" hence an attemt
> at humor with "unspecified squared". You know you have failed when the
> joke has to be explained.
>

OK, that makes a bit more sense. But it still wouldn't be unspecified
behaviour - Michael was looking for implementation defined behaviour
(i.e., the implementation would pick one way of handling overflow,
document it, and stick to it).

>
>>
>> "Unspecified" is used for things like the order of evaluation for "a +
>> b" - it is unspecified which is evaluated first. (That means the
>> compiler doesn't need to document it - it doesn't even need to be
>> consistent from run to run.)

Re: Specifying timing constraints was Re: Paper about ISO C

<sklq1e$qt0$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21346&group=comp.arch#21346

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!rocksolid2!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.arch
Subject: Re: Specifying timing constraints was Re: Paper about ISO C
Date: Tue, 19 Oct 2021 08:53:34 +0200
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <sklq1e$qt0$2@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk9ej9$fj9$1@dont-email.me> <jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org>
<skc7a9$698$1@dont-email.me> <skc905$85c$1@dont-email.me>
<skh20o$ji2$1@dont-email.me>
<4fc4f707-2d42-492a-bd41-f791141dbfb2n@googlegroups.com>
<skhjk3$9p4$1@dont-email.me>
<f9db2e75-2ec2-4572-b211-a8b2d6b3e0e6n@googlegroups.com>
<skjkqv$nd3$1@dont-email.me>
<0ba079c3-d672-47b3-b86d-cfc74520ca5dn@googlegroups.com>
<875ytupjzd.fsf@hotmail.com> <skk5h9$gth$1@dont-email.me>
<871r4ip9dm.fsf@hotmail.com> <87wnmanujt.fsf@hotmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 19 Oct 2021 06:53:34 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="8bc4cebc62c475127dc1ae785648adc4";
logging-data="27552"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18eM7raafFC9SOJCCEC7ZsF5t4NrN31yM8="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:YYZ7fgAW3GYfBdnQmtj6ShI/QZ8=
In-Reply-To: <87wnmanujt.fsf@hotmail.com>
Content-Language: en-GB
 by: David Brown - Tue, 19 Oct 2021 06:53 UTC

On 18/10/2021 18:53, clamky@hotmail.com wrote:
> clamky@hotmail.com writes:
>
>> David Brown <david.brown@hesbynett.no> writes:
>>
>>> On 18/10/2021 14:59, clamky@hotmail.com wrote:
>>>> Michael S <already5chosen@yahoo.com> writes:
>>>>
>>>>> On Monday, October 18, 2021 at 2:12:34 PM UTC+3, David Brown wrote:
>>>>>> On 18/10/2021 01:47, Victor Yodaiken wrote:
>>>>>>> On Sunday, October 17, 2021 at 11:39:37 AM UTC-5, David Brown wrote:
>>>>>>>> On 17/10/2021 16:40, Victor Yodaiken wrote:
>>>>>>>>> On Sunday, October 17, 2021 at 6:39:07 AM UTC-5, David Brown wrote:
>>>>>>>>>
> [..]
>
>>
>> 3.4.4
>> 1
>> unspecified behavior
>> use of an unspecified value, or other behavior where this
>> International Standard provides two or
>> more possibilities and imposes no further requirements on which is
>> chosen in any instance
>> 2
>> EXAMPLE An example of unspecified behavior is the order in which the
>> arguments to a function are evaluated.
>>
>
> [..]
>
> And only now "... or more ..." really registered, i plead temporal
> insanity. Sorry i was wrong. Guess this is a prime example of an ald
> adage's:
> Programmers are simpletons - they count one, two, many...
>

That's trolls, from the Discworld :-)

/Real/ programmers count 0, 1, 0, 1, 0, 1, ...

Re: Specifying timing constraints was Re: Paper about ISO C

<sklrl4$5g1$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21347&group=comp.arch#21347

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.arch
Subject: Re: Specifying timing constraints was Re: Paper about ISO C
Date: Tue, 19 Oct 2021 09:21:08 +0200
Organization: A noiseless patient Spider
Lines: 45
Message-ID: <sklrl4$5g1$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk9ej9$fj9$1@dont-email.me> <jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org>
<skc7a9$698$1@dont-email.me> <skc905$85c$1@dont-email.me>
<skh20o$ji2$1@dont-email.me>
<4fc4f707-2d42-492a-bd41-f791141dbfb2n@googlegroups.com>
<skhjk3$9p4$1@dont-email.me>
<f9db2e75-2ec2-4572-b211-a8b2d6b3e0e6n@googlegroups.com>
<skjkqv$nd3$1@dont-email.me>
<0ba079c3-d672-47b3-b86d-cfc74520ca5dn@googlegroups.com>
<skjshe$2up$1@dont-email.me>
<8af10f0d-80ae-4cf2-b2e1-048a72bef192n@googlegroups.com>
<skk6h7$ovp$1@dont-email.me>
<4fc7ef31-0248-4cff-a63f-cb8d00169f72n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 19 Oct 2021 07:21:08 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="8bc4cebc62c475127dc1ae785648adc4";
logging-data="5633"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+/ADh+QTYL5t86CNv2Mi+MAisZrXlCFn4="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:OiVCSew6lbA6hRzD8IFubZ/Eb84=
In-Reply-To: <4fc7ef31-0248-4cff-a63f-cb8d00169f72n@googlegroups.com>
Content-Language: en-GB
 by: David Brown - Tue, 19 Oct 2021 07:21 UTC

On 18/10/2021 19:00, Victor Yodaiken wrote:
> On Monday, October 18, 2021 at 11:14:33 AM UTC-5, David Brown wrote:
>
>> Relying on wrapping is ugly and error-prone. It encourages people to
>> write code that makes no logical sense, such as adding two positive
>> numbers and checking for them being negative.
>
> 1. Signed arithmetic is a representation of arithmetic in the residue ring of the integers mod 2^{k}

Not in standard C, and many other languages.

> 2. Signed arithmetic is a patchy approximation of arithmetic over the integers with known failure cases and
> unpredictable results and where the implication of x+1 > x and x <= INT_MAX is that INT_MAX < INT_MAX
>

Not in standard C, or any other language I know of. x + 1 is not
defined for x = INT_MAX, so it can have no implications.

> Of course 1 makes no logical sense. Bravo!
>

Try this exercise - find a random person, and ask them if "x + 1" is
always bigger than "x". Assuming you can make it past the "is this a
trick question?" stage, you'll get a "yes". C integer arithmetic
matches this.

Find another random person and ask them if they know what a residue ring
is. Ask them if they think ℤ/2ⁿ is a natural way to count and do
arithmetic. Ask them if they know why this is similar, but not
identical, to two's complement integers with wrapping. (Hint - think
about division.)

Ask them if they think a logical and natural numbering system should
follow basic rules of arithmetic as much as possible in the limited space.

Ask them if it makes more sense to say "these numbers are too big, you
can't add them", or if it is more sensible to say "these numbers are big
- you'll get a negative result if you add them".

Undefined signed integer overflow is the /only/ sensible and logical
choice. There is /no/ correct answer for overflowing arithmetic in any
simple, useful sense - so the sane way to handle it is to say "don't do
it". It's hardly the most difficult rule to follow.

Re: Specifying timing constraints was Re: Paper about ISO C

<87sfwxzdey.fsf@hotmail.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21348&group=comp.arch#21348

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!aioe.org!xcrumNapWYKcczN4Ruh1Kw.user.46.165.242.75.POSTED!not-for-mail
From: cla...@hotmail.com
Newsgroups: comp.arch
Subject: Re: Specifying timing constraints was Re: Paper about ISO C
Date: Tue, 19 Oct 2021 10:23:01 +0300
Organization: Aioe.org NNTP Server
Message-ID: <87sfwxzdey.fsf@hotmail.com>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk9ej9$fj9$1@dont-email.me>
<jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org>
<skc7a9$698$1@dont-email.me> <skc905$85c$1@dont-email.me>
<skh20o$ji2$1@dont-email.me>
<4fc4f707-2d42-492a-bd41-f791141dbfb2n@googlegroups.com>
<skhjk3$9p4$1@dont-email.me>
<f9db2e75-2ec2-4572-b211-a8b2d6b3e0e6n@googlegroups.com>
<skjkqv$nd3$1@dont-email.me>
<0ba079c3-d672-47b3-b86d-cfc74520ca5dn@googlegroups.com>
<875ytupjzd.fsf@hotmail.com> <skk5h9$gth$1@dont-email.me>
<871r4ip9dm.fsf@hotmail.com> <87wnmanujt.fsf@hotmail.com>
<sklq1e$qt0$2@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="2960"; posting-host="xcrumNapWYKcczN4Ruh1Kw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
Cancel-Lock: sha1:Jr31k2GdZUNSEYatJJ82iq3O0x8=
X-Notice: Filtered by postfilter v. 0.9.2
 by: cla...@hotmail.com - Tue, 19 Oct 2021 07:23 UTC

David Brown <david.brown@hesbynett.no> writes:

> On 18/10/2021 18:53, clamky@hotmail.com wrote:
>> clamky@hotmail.com writes:

[..]

>
> That's trolls, from the Discworld :-)

Thanks! I've first encountered this adage (translated) an aen ago and it
stuck in my brain. However, it appears, you are also wrong [1] To make
this post NG topical - [1] points that Setun [2] was created by trolls,
not tame .no variety, but proper, fearless, soviet beasts.

>
> /Real/ programmers count 0, 1, 0, 1, 0, 1, ...

;)

[1] https://www.tes.com/teaching-resource/discworld-maths-starter-counting-in-troll-11027536
[2] https://en.wikipedia.org/wiki/Setun

Re: Specifying timing constraints was Re: Paper about ISO C

<sklt24$dak$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21349&group=comp.arch#21349

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.arch
Subject: Re: Specifying timing constraints was Re: Paper about ISO C
Date: Tue, 19 Oct 2021 09:45:08 +0200
Organization: A noiseless patient Spider
Lines: 124
Message-ID: <sklt24$dak$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk9ej9$fj9$1@dont-email.me> <jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org>
<skc7a9$698$1@dont-email.me> <skc905$85c$1@dont-email.me>
<skh20o$ji2$1@dont-email.me>
<4fc4f707-2d42-492a-bd41-f791141dbfb2n@googlegroups.com>
<skhjk3$9p4$1@dont-email.me>
<f9db2e75-2ec2-4572-b211-a8b2d6b3e0e6n@googlegroups.com>
<skjkqv$nd3$1@dont-email.me>
<0ba079c3-d672-47b3-b86d-cfc74520ca5dn@googlegroups.com>
<86a6j6l8ci.fsf@linuxsc.com> <LClbJ.602$xjIc.241@fx01.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 19 Oct 2021 07:45:08 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="8bc4cebc62c475127dc1ae785648adc4";
logging-data="13652"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19NBoqhPgZvKYVblV+naWwFY++tVgopYXo="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:vaY0K//NagEpNhNMKc8z1ciRRJ0=
In-Reply-To: <LClbJ.602$xjIc.241@fx01.iad>
Content-Language: en-GB
 by: David Brown - Tue, 19 Oct 2021 07:45 UTC

On 18/10/2021 23:23, EricP wrote:
> Tim Rentsch wrote:
>> Michael S <already5chosen@yahoo.com> writes:
>>
>>>> [..sarcastic comments regarding signed overflow..]
>>
>>> Don't be silly.
>>> The best solution does not involve magic.
>>> Something like that will do:
>>>
>>> Signed overflow is implementation-defined, but in constrained way.
>>> Possible options are
>>> 1. two-complement wrap-around
>>> 2. trap
>>> 3. saturation
>>> 4. one-complement wrap-around, if there exist a member of
>>>    committee that care about it
>>>
>>> Implementation has to specify the chosen option clearly in
>>> documentation.  It is allowed to select an option with special
>>> flag.  It is not allowed to make option dependent on optimization
>>> settings.  If the chosen option is trap and overflow happens in
>>> intermediate result of complex expression, but not in the final
>>> result than it's it's legal for trap to be intermittent and
>>> dependent on ether optimization level or phase of the moon, but
>>> not both.
>>
>> My sense is this idea is not much better than how things are
>> now.  I would like to see the decision be under control of
>> the source code, perhaps by means of a #pragma:
>>
>>     #pragma STDC SIGNED_OVERFLOW WRAP
>>     #pragma STDC SIGNED_OVERFLOW TRAP
>>     #pragma STDC SIGNED_OVERFLOW SATURATE
>>     #pragma STDC SIGNED_OVERFLOW UNDEFINED
>>     (..others?..)
>>
>> If it's important, implementations might be allowed not to
>> implement some or all of these choices;  but if they don't then
>> they must at least check the #pragma line for legality and fail
>> the compilation if they cannot accommodate the choice indicated
>> (or if the #pragma STDC doesn't scan for some reason).
>
> Gcc C already has the compiler switch -ftrapv to enable signed integer
> overflow checks (operators are implemented as subroutine calls).
>
> The problem with such pragmas in C is the same as compiler switches:
> they cause many false positives (overflow traps) because they are too
> much of a blunt object. As a consequence people just turn them off.

There are more problems than that. Consider "y = x + 3 - 2;". (Imagine
it is the result of a set of macros, or inline functions and constant
propagation, rather than a hand-written expression.) Can a compiler
change that to "y = x + 1;" with overflow checking there? Does it need
to do two operations, checking twice?

Requiring strict overflow trapping would cripple the performance of a
lot of code. That's fine for debugging (like gcc
"-fsanitize=signed-integer-overflow"), but not for normal code.

I believe that these days that "-ftrapv" is considered broken beyond
repair in gcc - it might work in some cases, but you'll get false
positives and false negatives and little in the way of guarantees of how
it interacts with optimisations and strength reductions. The sanitizer
is the modern way to handle this.

>
> A number of studies of real world code have shown that it is a
> mixture of signed and unsigned, checked and unchecked assumptions
> *often within a single expression*.
>
> E.g. these folks tap into clang's front end to inject checks into code.
>
> Understanding Integer Overflow in C/C++, 2015
> https://wdtz.org/files/tosem15.pdf
>
> Consider a hypothetical line from a codec:
>
>   signal = signal + impulse[i + j];
>
> In this expression, i+j are signed integers and should be added using
> checked arithmetic, the array index then checked against array bounds,
> the array element address addition calculated using unsigned modulo
> arithmetic, and signal value added using saturating arithmetic.
>
> Note also that some unsigned wrap arounds are bugs, some not.
> It depends on the programmers intent.
>
> This is why the VAX with it PSW global flag enabling overflow detect
> had problems - real code would have to keep switching it on and off,
> which would cause a large overhead so they just left it on for
> Fortran or Ada and lived with occasional false overflow traps.
> Which is why Alpha has separate instructions for Add and AddTrapOverflow.
>
> The only mechanism I can think of that can handle that kind of
> flexibility smoothly would be based on multiple language data types,
> and an ISA with separate instructions for each operation on each type.
>

For most ISA's, -ftrapv would generate some kind of "add with flags"
instruction followed by a "trap if overflow flag set". Some might do
the arithmetic with wider operands and then check the result. In
general, it's a costly business - and operations involving flags are
typically a pain for scheduling and pipelining on superscaler
processors. It's fine for bug-chasing, but not for efficient end products.

And then you have the trouble with mixing signed and unsigned operands,
as you mention. This is already quite counter-intuitive in C for many
people, as the operation is done as unsigned arithmetic. It is worse if
the programmer expected overflow trapping. (I like gcc's
"-Wsign-conversion" warning, but false positives are not uncommon.)

I think the only good answer here if you want tight control of your
overflows, is to switch from C. Ada will give you all sorts of
possibilities. Java will give you two's complement wrapping, fully
defined (thus no errors even when the results are wrong), for those that
want that. C++ lets you build classes to do exactly what you want,
whatever that may be.

But standardised pragmas would be a good step forward in C, IMHO.

Re: Specifying timing constraints was Re: Paper about ISO C

<sklv7i$r0b$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21350&group=comp.arch#21350

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.arch
Subject: Re: Specifying timing constraints was Re: Paper about ISO C
Date: Tue, 19 Oct 2021 10:22:09 +0200
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <sklv7i$r0b$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk9ej9$fj9$1@dont-email.me> <jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org>
<skc7a9$698$1@dont-email.me> <skc905$85c$1@dont-email.me>
<skh20o$ji2$1@dont-email.me>
<4fc4f707-2d42-492a-bd41-f791141dbfb2n@googlegroups.com>
<skhjk3$9p4$1@dont-email.me>
<f9db2e75-2ec2-4572-b211-a8b2d6b3e0e6n@googlegroups.com>
<skjkqv$nd3$1@dont-email.me>
<0ba079c3-d672-47b3-b86d-cfc74520ca5dn@googlegroups.com>
<875ytupjzd.fsf@hotmail.com> <skk5h9$gth$1@dont-email.me>
<871r4ip9dm.fsf@hotmail.com> <87wnmanujt.fsf@hotmail.com>
<sklq1e$qt0$2@dont-email.me> <87sfwxzdey.fsf@hotmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 19 Oct 2021 08:22:10 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="8bc4cebc62c475127dc1ae785648adc4";
logging-data="27659"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+sBtG9UiY1m08b0Dzu4pE9FkPeSCzP+vY="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:sEIoE497uunjV1x5pM3aN21tb+A=
In-Reply-To: <87sfwxzdey.fsf@hotmail.com>
Content-Language: en-GB
 by: David Brown - Tue, 19 Oct 2021 08:22 UTC

On 19/10/2021 09:23, clamky@hotmail.com wrote:
> David Brown <david.brown@hesbynett.no> writes:
>
>> On 18/10/2021 18:53, clamky@hotmail.com wrote:
>>> clamky@hotmail.com writes:
>
> [..]
>
>>
>> That's trolls, from the Discworld :-)
>
> Thanks! I've first encountered this adage (translated) an aen ago and it
> stuck in my brain. However, it appears, you are also wrong [1] To make
> this post NG topical - [1] points that Setun [2] was created by trolls,
> not tame .no variety, but proper, fearless, soviet beasts.
>

Many things, good and bad, can be said of the old Soviets - but they
were never afraid to try something different!

>>
>> /Real/ programmers count 0, 1, 0, 1, 0, 1, ...
>
> ;)
>
> [1] https://www.tes.com/teaching-resource/discworld-maths-starter-counting-in-troll-11027536
> [2] https://en.wikipedia.org/wiki/Setun
>

Re: Specifying timing constraints was Re: Paper about ISO C

<2021Oct19.105118@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21351&group=comp.arch#21351

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: Specifying timing constraints was Re: Paper about ISO C
Date: Tue, 19 Oct 2021 08:51:18 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 12
Distribution: world
Message-ID: <2021Oct19.105118@mips.complang.tuwien.ac.at>
References: <87fstdumxd.fsf@hotmail.com> <f9db2e75-2ec2-4572-b211-a8b2d6b3e0e6n@googlegroups.com> <skjkqv$nd3$1@dont-email.me> <0ba079c3-d672-47b3-b86d-cfc74520ca5dn@googlegroups.com> <skjshe$2up$1@dont-email.me> <8af10f0d-80ae-4cf2-b2e1-048a72bef192n@googlegroups.com> <skk6h7$ovp$1@dont-email.me> <4fc7ef31-0248-4cff-a63f-cb8d00169f72n@googlegroups.com> <skkc39$ubi$2@newsreader4.netcologne.de> <cb406117-6bc6-4ccd-a228-0591187378fdn@googlegroups.com> <skllj9$qel$1@newsreader4.netcologne.de>
Injection-Info: reader02.eternal-september.org; posting-host="70d6a91d67886e4082d730b0666cc883";
logging-data="2006"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18HkHqq3L3kEXg/c5Y8OgIq"
Cancel-Lock: sha1:cRXUth5NoQs7RVgMjTq7JQfziLA=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Tue, 19 Oct 2021 08:51 UTC

Thomas Koenig <tkoenig@netcologne.de> writes:
>If you are not trying to convince anybody, but
>rather would like to stir up discussion for the sake of discussion,
>then you're on the right track.

I don't think so. I am less likely to reply to a badly formatted
post, and I think others are, too.

- anton
--
'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>

Pages:123456789101112131415161718192021222324252627282930313233
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor