Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Do not underestimate the value of print statements for debugging.


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: Paper about ISO C

<2021Nov4.182748@mips.complang.tuwien.ac.at>

  copy mid

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

  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: Paper about ISO C
Date: Thu, 04 Nov 2021 17:27:48 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 36
Message-ID: <2021Nov4.182748@mips.complang.tuwien.ac.at>
References: <87fstdumxd.fsf@hotmail.com> <2021Oct27.231122@mips.complang.tuwien.ac.at> <slgs05$7rf$1@dont-email.me> <2021Nov1.182821@mips.complang.tuwien.ac.at> <slpo0e$34b$1@newsreader4.netcologne.de> <2021Nov2.094824@mips.complang.tuwien.ac.at> <d71f0f03-ba1b-462c-bf7e-236003255918n@googlegroups.com> <2021Nov2.173551@mips.complang.tuwien.ac.at> <sltddc$btq$1@dont-email.me> <2021Nov3.092521@mips.complang.tuwien.ac.at> <sluebv$icv$1@dont-email.me> <4620d9be-e530-4dbf-8672-ca45bdb2f248n@googlegroups.com>
Injection-Info: reader02.eternal-september.org; posting-host="27d5d3d24f90d1b7ef5a0eeee00162e3";
logging-data="29936"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX184Z3HhVVurITfYOohabSs9"
Cancel-Lock: sha1:oxKreolROPdKF6lfGI4MubV8aeE=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Thu, 4 Nov 2021 17:27 UTC

Quadibloc <jsavard@ecn.ab.ca> writes:
>On Wednesday, November 3, 2021 at 10:45:53 AM UTC-6, David Brown wrote:
>> Given your past history, you
>> might find it useful to use a pseudonym.
>
>Um, that wouldn't help.
>
>The issue about which Anton Ertl is concerned is... one that a *lot* of
>people are concerned about.
....
>Basically, the question of whether C should embrace the future, or stay
>compatible with K&R C,

But that's not at all the issue I am concerned with.

The issue is: If a program has been tested and works on one or several
versions of a C compiler, and it does not work on a new version of the
same compiler on the same architecture(s), is it a regression in the
compiler (my position), or has the program been broken all the time,
and the earlier compiler releases were just not advanced enough to
expose this brokenness earlier.

>Since the other side has already won, C99 being an official standard
>and all that, I think that forking gcc is the only reasonable measure
>available at this late date.

Providing a saner alternative to gcc and clang may indeed be the
answer. However, gcc (and clang) are complex and by now nasal demons
have grown deep and intricate roots in the vast source code of these
projects, so basing the alternative of gcc or clang is probably not
the most effective approach.

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

Re: Paper about ISO C

<sm18dn$2p0$1@newsreader4.netcologne.de>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!paganini.bofh.team!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd6-a34-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Thu, 4 Nov 2021 18:22:47 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <sm18dn$2p0$1@newsreader4.netcologne.de>
References: <87fstdumxd.fsf@hotmail.com> <slatma$8au$1@dont-email.me>
<2021Oct27.193426@mips.complang.tuwien.ac.at>
<slc6kj$vv9$1@newsreader4.netcologne.de>
<2021Oct27.231122@mips.complang.tuwien.ac.at> <slgs05$7rf$1@dont-email.me>
<2021Nov1.182821@mips.complang.tuwien.ac.at>
<slpo0e$34b$1@newsreader4.netcologne.de>
<2021Nov2.094824@mips.complang.tuwien.ac.at>
<d71f0f03-ba1b-462c-bf7e-236003255918n@googlegroups.com>
<2021Nov2.173551@mips.complang.tuwien.ac.at> <sltddc$btq$1@dont-email.me>
<2021Nov3.092521@mips.complang.tuwien.ac.at>
Injection-Date: Thu, 4 Nov 2021 18:22:47 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd6-a34-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd6:a34:0:7285:c2ff:fe6c:992d";
logging-data="2848"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Thu, 4 Nov 2021 18:22 UTC

Anton Ertl <anton@mips.complang.tuwien.ac.at> schrieb:

> My position is basically that a responsible maintainer for a
> widely-used compiler does not break existing source code

Question: You mentioned tail call optimization in one of
your posts.

Should compilers be mandated to copy arguments for

int bar (int a, int b, int c);

int foo(int a, int b, int c)
{ if (a > 0)
return bar(a,b,c);
else
return -1;
}

?

Re: Paper about ISO C

<sm1ioa$h41$1@dont-email.me>

  copy mid

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

  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: Paper about ISO C
Date: Thu, 4 Nov 2021 22:19:05 +0100
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <sm1ioa$h41$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com>
<2021Oct27.231122@mips.complang.tuwien.ac.at> <slgs05$7rf$1@dont-email.me>
<2021Nov1.182821@mips.complang.tuwien.ac.at>
<slpo0e$34b$1@newsreader4.netcologne.de>
<2021Nov2.094824@mips.complang.tuwien.ac.at>
<d71f0f03-ba1b-462c-bf7e-236003255918n@googlegroups.com>
<2021Nov2.173551@mips.complang.tuwien.ac.at> <sltddc$btq$1@dont-email.me>
<2021Nov3.092521@mips.complang.tuwien.ac.at> <sluebv$icv$1@dont-email.me>
<4620d9be-e530-4dbf-8672-ca45bdb2f248n@googlegroups.com>
<2021Nov4.182748@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 4 Nov 2021 21:19:06 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="b16fcafc959664c7224f37177f71b2e9";
logging-data="17537"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19sf4BpQsuajN7xg3CjmPXa/0rusDn3V5s="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:4eoVVKwiBgVAtYqQAksQlOfwPzw=
In-Reply-To: <2021Nov4.182748@mips.complang.tuwien.ac.at>
Content-Language: en-GB
 by: David Brown - Thu, 4 Nov 2021 21:19 UTC

On 04/11/2021 18:27, Anton Ertl wrote:
> Quadibloc <jsavard@ecn.ab.ca> writes:
>> On Wednesday, November 3, 2021 at 10:45:53 AM UTC-6, David Brown wrote:
>>> Given your past history, you
>>> might find it useful to use a pseudonym.
>>
>> Um, that wouldn't help.
>>
>> The issue about which Anton Ertl is concerned is... one that a *lot* of
>> people are concerned about.
> ...
>> Basically, the question of whether C should embrace the future, or stay
>> compatible with K&R C,
>
> But that's not at all the issue I am concerned with.
>
> The issue is: If a program has been tested and works on one or several
> versions of a C compiler, and it does not work on a new version of the
> same compiler on the same architecture(s), is it a regression in the
> compiler (my position), or has the program been broken all the time,
> and the earlier compiler releases were just not advanced enough to
> expose this brokenness earlier.
>

You cannot possibly justify that position as a generality. Should
compilers enforce bug-for-bug compatibility in the event that an error
is found in the previous version of the compiler? Should a new compiler
be unable to add new features or extensions within the reserved
namespace, just because someone has previously written code that defined
their own macro named _Static_assert or their own function named
__builtin__memset ?

I know that's not what you were thinking of - but that is what you said.
This is why I am so strongly against your ideas about consistency and
undefined behaviour - your statements are so sweeping that they cover
things that are clearly ridiculous. If you want to pick /specific/
classes of UB and give /specific/ definitions to how you want those to
behave, then we can get somewhere. I might not agree that the new
semantics you pick are an improvement (or not an improvement for my own
use), but I will happily appreciate that people might want to add new
semantics to the language.

Re: Paper about ISO C

<3319e5a3-0f12-4a7f-8056-289066a982b5n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a37:44c8:: with SMTP id r191mr44302166qka.507.1636061942800;
Thu, 04 Nov 2021 14:39:02 -0700 (PDT)
X-Received: by 2002:a9d:60c:: with SMTP id 12mr32958845otn.94.1636061942567;
Thu, 04 Nov 2021 14:39:02 -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: Thu, 4 Nov 2021 14:39:02 -0700 (PDT)
In-Reply-To: <sm18dn$2p0$1@newsreader4.netcologne.de>
Injection-Info: google-groups.googlegroups.com; posting-host=104.59.204.55; posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 104.59.204.55
References: <87fstdumxd.fsf@hotmail.com> <slatma$8au$1@dont-email.me>
<2021Oct27.193426@mips.complang.tuwien.ac.at> <slc6kj$vv9$1@newsreader4.netcologne.de>
<2021Oct27.231122@mips.complang.tuwien.ac.at> <slgs05$7rf$1@dont-email.me>
<2021Nov1.182821@mips.complang.tuwien.ac.at> <slpo0e$34b$1@newsreader4.netcologne.de>
<2021Nov2.094824@mips.complang.tuwien.ac.at> <d71f0f03-ba1b-462c-bf7e-236003255918n@googlegroups.com>
<2021Nov2.173551@mips.complang.tuwien.ac.at> <sltddc$btq$1@dont-email.me>
<2021Nov3.092521@mips.complang.tuwien.ac.at> <sm18dn$2p0$1@newsreader4.netcologne.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3319e5a3-0f12-4a7f-8056-289066a982b5n@googlegroups.com>
Subject: Re: Paper about ISO C
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Thu, 04 Nov 2021 21:39:02 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 32
 by: MitchAlsup - Thu, 4 Nov 2021 21:39 UTC

On Thursday, November 4, 2021 at 1:22:50 PM UTC-5, Thomas Koenig wrote:
> Anton Ertl <an...@mips.complang.tuwien.ac.at> schrieb:
> > My position is basically that a responsible maintainer for a
> > widely-used compiler does not break existing source code
> Question: You mentioned tail call optimization in one of
> your posts.
>
> Should compilers be mandated to copy arguments for
>
> int bar (int a, int b, int c);
>
> int foo(int a, int b, int c)
> {
> if (a > 0)
> return bar(a,b,c);
> else
> return -1;
> }
>
My 66000
<
GLOBAL foo
ENTRY foo
foo:
PEQ0 R1,{3,{TEE}} // {1,{T}} and {2,{TE} also work.
JMP bar
MOV R1,#-1
RET
<
Since arguments are passed in registers, the simple JMP "copies" the
arguments forward. no stack frame is built, and the control transfer to
bar takes with it the return address from foo.
> ?

Re: Paper about ISO C

<ecac9895-c898-40bf-8733-c90a3c498712n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:622a:1716:: with SMTP id h22mr35694061qtk.224.1636062341048;
Thu, 04 Nov 2021 14:45:41 -0700 (PDT)
X-Received: by 2002:a05:6820:28d:: with SMTP id q13mr5558089ood.59.1636062340795;
Thu, 04 Nov 2021 14:45:40 -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: Thu, 4 Nov 2021 14:45:40 -0700 (PDT)
In-Reply-To: <sm1ioa$h41$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=104.59.204.55; posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 104.59.204.55
References: <87fstdumxd.fsf@hotmail.com> <2021Oct27.231122@mips.complang.tuwien.ac.at>
<slgs05$7rf$1@dont-email.me> <2021Nov1.182821@mips.complang.tuwien.ac.at>
<slpo0e$34b$1@newsreader4.netcologne.de> <2021Nov2.094824@mips.complang.tuwien.ac.at>
<d71f0f03-ba1b-462c-bf7e-236003255918n@googlegroups.com> <2021Nov2.173551@mips.complang.tuwien.ac.at>
<sltddc$btq$1@dont-email.me> <2021Nov3.092521@mips.complang.tuwien.ac.at>
<sluebv$icv$1@dont-email.me> <4620d9be-e530-4dbf-8672-ca45bdb2f248n@googlegroups.com>
<2021Nov4.182748@mips.complang.tuwien.ac.at> <sm1ioa$h41$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ecac9895-c898-40bf-8733-c90a3c498712n@googlegroups.com>
Subject: Re: Paper about ISO C
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Thu, 04 Nov 2021 21:45:41 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 61
 by: MitchAlsup - Thu, 4 Nov 2021 21:45 UTC

On Thursday, November 4, 2021 at 4:19:08 PM UTC-5, David Brown wrote:
> On 04/11/2021 18:27, Anton Ertl wrote:
> > Quadibloc <jsa...@ecn.ab.ca> writes:
> >> On Wednesday, November 3, 2021 at 10:45:53 AM UTC-6, David Brown wrote:
> >>> Given your past history, you
> >>> might find it useful to use a pseudonym.
> >>
> >> Um, that wouldn't help.
> >>
> >> The issue about which Anton Ertl is concerned is... one that a *lot* of
> >> people are concerned about.
> > ...
> >> Basically, the question of whether C should embrace the future, or stay
> >> compatible with K&R C,
> >
> > But that's not at all the issue I am concerned with.
> >
> > The issue is: If a program has been tested and works on one or several
> > versions of a C compiler, and it does not work on a new version of the
> > same compiler on the same architecture(s), is it a regression in the
> > compiler (my position), or has the program been broken all the time,
> > and the earlier compiler releases were just not advanced enough to
> > expose this brokenness earlier.
> >
> You cannot possibly justify that position as a generality. Should
> compilers enforce bug-for-bug compatibility in the event that an error
> is found in the previous version of the compiler? Should a new compiler
> be unable to add new features or extensions within the reserved
> namespace, just because someone has previously written code that defined
> their own macro named _Static_assert or their own function named
> __builtin__memset ?
<
I actually lived though such an example, but with a CAD tool.
<
After using a particular CAD tool for several years, we knew where most
of the nasal deamons lived, and wrote code so as to avoid those. The tool
supplied wanted to migrate the whole team forward, but when tested on
our working {makes reliable tapeouts for mask manufacturing} the new
crashed and burned. In effect, tool vendor wanted us to pay big-$$$ for
a tool that would cost us big $$$ to update the current (and working)
data bases of our parts.
<
We said no.
<
In addition, the new tool only ran on SOLARIS while the old tool ran on
SUN-O/S and had "a much more user friendly licensing system".
<
{Circa 1994}
>
> I know that's not what you were thinking of - but that is what you said.
> This is why I am so strongly against your ideas about consistency and
> undefined behaviour - your statements are so sweeping that they cover
> things that are clearly ridiculous. If you want to pick /specific/
> classes of UB and give /specific/ definitions to how you want those to
> behave, then we can get somewhere. I might not agree that the new
> semantics you pick are an improvement (or not an improvement for my own
> use), but I will happily appreciate that people might want to add new
> semantics to the language.
<
From the comp.arch layer of understanding::
<
What is it that ISAs can do to minimize the space of UB ?

Re: Paper about ISO C

<sm1mgr$dt6$1@newsreader4.netcologne.de>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd6-a34-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Thu, 4 Nov 2021 22:23:23 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <sm1mgr$dt6$1@newsreader4.netcologne.de>
References: <87fstdumxd.fsf@hotmail.com>
<2021Oct27.231122@mips.complang.tuwien.ac.at> <slgs05$7rf$1@dont-email.me>
<2021Nov1.182821@mips.complang.tuwien.ac.at>
<slpo0e$34b$1@newsreader4.netcologne.de>
<2021Nov2.094824@mips.complang.tuwien.ac.at>
<d71f0f03-ba1b-462c-bf7e-236003255918n@googlegroups.com>
<2021Nov2.173551@mips.complang.tuwien.ac.at> <sltddc$btq$1@dont-email.me>
<2021Nov3.092521@mips.complang.tuwien.ac.at> <sluebv$icv$1@dont-email.me>
<4620d9be-e530-4dbf-8672-ca45bdb2f248n@googlegroups.com>
<2021Nov4.182748@mips.complang.tuwien.ac.at> <sm1ioa$h41$1@dont-email.me>
<ecac9895-c898-40bf-8733-c90a3c498712n@googlegroups.com>
Injection-Date: Thu, 4 Nov 2021 22:23:23 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd6-a34-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd6:a34:0:7285:c2ff:fe6c:992d";
logging-data="14246"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Thu, 4 Nov 2021 22:23 UTC

MitchAlsup <MitchAlsup@aol.com> schrieb:

> From the comp.arch layer of understanding::
><
> What is it that ISAs can do to minimize the space of UB ?

We have discussed part of this before, but here is a bit
of an expansion (and some repetition).

There are tools to find undefined behavior (or erroneous programs),
ranging from sanitizers (which add a low factor to execution time,
maybe two or so) to really heavy-handed tools like valgrind which
find a _lot_ of errors while making the code run abysmally slow.

Think of ways that an ISA could be designed to speed up those tests.
Zero overhead is almost certainly unreachable, but even reducing
the speed overhead of checked code would help a lot.

Going through the CERT coding standards, look for what can
be implemented either efficiently or at zero cost. An example:

5.1 INT30-C. Ensure that unsigned integer operations do not wrap.

Integer values must not be allowed to wrap, especially if they
are used in any of the following ways:

* Integer operands of any pointer arithmetic, including array
indexing

* The assignment expression for the declaration of a variable
length array

* The postfix expression preceding square brackets [] or the
expression in square brackets [] of a subscripted designation of
an element of an array object

* Function arguments of type size_t or rsize_t (for example,
an argument to a memory allocation function)

* In security-critical code

and they give the following example as a compliant solution:

void func(unsigned int ui_a, unsigned int ui_b) {
unsigned int usum;
if (UINT_MAX - ui_a < ui_b) {
/* Handle error */
} else {
usum = ui_a + ui_b;
}
/* ... */
}

Also of interest are the chapters regarding arrays, characters
and strings and memory management.

In an ideal world, all checks would be zero overhead, so everybody
would run every check all the time. Not likely to happen, though :-)

Re: Paper about ISO C

<2021Nov5.000057@mips.complang.tuwien.ac.at>

  copy mid

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

  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: Paper about ISO C
Date: Thu, 04 Nov 2021 23:00:57 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 34
Message-ID: <2021Nov5.000057@mips.complang.tuwien.ac.at>
References: <87fstdumxd.fsf@hotmail.com> <2021Nov2.094824@mips.complang.tuwien.ac.at> <d71f0f03-ba1b-462c-bf7e-236003255918n@googlegroups.com> <2021Nov2.173551@mips.complang.tuwien.ac.at> <sltddc$btq$1@dont-email.me> <2021Nov3.092521@mips.complang.tuwien.ac.at> <sluebv$icv$1@dont-email.me> <4620d9be-e530-4dbf-8672-ca45bdb2f248n@googlegroups.com> <2021Nov4.182748@mips.complang.tuwien.ac.at> <sm1ioa$h41$1@dont-email.me> <ecac9895-c898-40bf-8733-c90a3c498712n@googlegroups.com>
Injection-Info: reader02.eternal-september.org; posting-host="6abc18676fb7eef525c47edc1fbe1446";
logging-data="3214"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18YNLRb9Twu0oR6scbzxqSA"
Cancel-Lock: sha1:VHzLxd2EYEoiJZ66sEgaNCiDszI=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Thu, 4 Nov 2021 23:00 UTC

MitchAlsup <MitchAlsup@aol.com> writes:
>From the comp.arch layer of understanding::
><
>What is it that ISAs can do to minimize the space of UB ?

Not sure what you mean by that, but let me answer "What can in ISA do
to make UB attractive (or less so)."

The major reason why some people find undefined behaviour on integer
overflow so attractive is the fact that the decision to go with
I32LP64 requires sign-extending here and there with -fwrapv, e.g., with
loops like

for (int i=0; i<n; i++)
r+=a[i];

The address of a is 64 bits, but i is a signed 32-bit value, and needs
to be sign-extended with -fwrapv when forming a+i on every iteration
of the loop. If the instruction generated for i++ sign-extends (like
Alpha's addl, but then Alpha have a similar problem if i was defined
as unsigned; so we would need both sign-extending and zero-extending
variants), you don't need to sign-extend with an extra intruction.
Alternatively, if the address computation supports sign-extended
32-bit arguments (IIRC Aarch64 has such addressing modes), this is
another way of avoiding the extra instruction. Finally,
sign-extension instructions could be made zero-cost in implementations
(like zero-extending is in some implementations), this might also
reduce the attraction (but I guess that the effect would be smaller,
because an instruction always has a psychological cost.

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

Re: Paper about ISO C

<26c1bc56-4e5c-4da5-a16f-3ee778478dccn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:6214:2aa9:: with SMTP id js9mr36777238qvb.67.1636070182337;
Thu, 04 Nov 2021 16:56:22 -0700 (PDT)
X-Received: by 2002:a05:6808:10d2:: with SMTP id s18mr19169777ois.30.1636070182127;
Thu, 04 Nov 2021 16:56:22 -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: Thu, 4 Nov 2021 16:56:21 -0700 (PDT)
In-Reply-To: <2021Nov5.000057@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=104.59.204.55; posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 104.59.204.55
References: <87fstdumxd.fsf@hotmail.com> <2021Nov2.094824@mips.complang.tuwien.ac.at>
<d71f0f03-ba1b-462c-bf7e-236003255918n@googlegroups.com> <2021Nov2.173551@mips.complang.tuwien.ac.at>
<sltddc$btq$1@dont-email.me> <2021Nov3.092521@mips.complang.tuwien.ac.at>
<sluebv$icv$1@dont-email.me> <4620d9be-e530-4dbf-8672-ca45bdb2f248n@googlegroups.com>
<2021Nov4.182748@mips.complang.tuwien.ac.at> <sm1ioa$h41$1@dont-email.me>
<ecac9895-c898-40bf-8733-c90a3c498712n@googlegroups.com> <2021Nov5.000057@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <26c1bc56-4e5c-4da5-a16f-3ee778478dccn@googlegroups.com>
Subject: Re: Paper about ISO C
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Thu, 04 Nov 2021 23:56:22 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 53
 by: MitchAlsup - Thu, 4 Nov 2021 23:56 UTC

On Thursday, November 4, 2021 at 6:21:39 PM UTC-5, Anton Ertl wrote:
> MitchAlsup <Mitch...@aol.com> writes:
> >From the comp.arch layer of understanding::
> ><
> >What is it that ISAs can do to minimize the space of UB ?
> Not sure what you mean by that, but let me answer "What can in ISA do
> to make UB attractive (or less so)."
>
> The major reason why some people find undefined behaviour on integer
> overflow so attractive is the fact that the decision to go with
> I32LP64 requires sign-extending here and there with -fwrapv, e.g., with
> loops like
>
> for (int i=0; i<n; i++)
> r+=a[i];
>
> The address of a is 64 bits, but i is a signed 32-bit value, and needs
> to be sign-extended with -fwrapv when forming a+i on every iteration
> of the loop.
<
For a new ISA, why would anyone go with I32LP64 why not ILP64 ?
<
But why can 'n' not be checked for being "too big" before running the loop
and avoid all of the a+i checking "in the loop". Here, the check seems easy
enough (n>=0):: but it seems the real problem is that there is nothing close
to the loop supplying the bounds for a[] !!?!
<
> If the instruction generated for i++ sign-extends (like
> Alpha's addl, but then Alpha have a similar problem if i was defined
> as unsigned; so we would need both sign-extending and zero-extending
> variants), you don't need to sign-extend with an extra intruction.
<
In I32LP64 codes, Brian's My 66000 C compiler spits out copious
quantities of EXT Rx,Rx,<31:0> // extract the lower 32 bits and sign
extend.
<
> Alternatively, if the address computation supports sign-extended
> 32-bit arguments (IIRC Aarch64 has such addressing modes), this is
> another way of avoiding the extra instruction. Finally,
> sign-extension instructions could be made zero-cost in implementations
> (like zero-extending is in some implementations), this might also
> reduce the attraction (but I guess that the effect would be smaller,
> because an instruction always has a psychological cost.
> - anton
> --
> 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
> Mitch Alsup, <c17fcd89-f024-40e7...@googlegroups.com>
<
But I was wondering more about doing things like::
<
int a >> int b; // where b is allowed to be negative
int a << int b; // where b is allowed to be negative
<
And when a shift count is negative, the shift is performed in the "other" direction.

Re: Paper about ISO C

<826ad4e3-8b1f-4fdd-819d-e46647e30019n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ad4:54ca:: with SMTP id j10mr31594176qvx.2.1636071107977;
Thu, 04 Nov 2021 17:11:47 -0700 (PDT)
X-Received: by 2002:a05:6808:199d:: with SMTP id bj29mr755304oib.37.1636071107645;
Thu, 04 Nov 2021 17:11:47 -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: Thu, 4 Nov 2021 17:11:47 -0700 (PDT)
In-Reply-To: <sm1mgr$dt6$1@newsreader4.netcologne.de>
Injection-Info: google-groups.googlegroups.com; posting-host=104.59.204.55; posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 104.59.204.55
References: <87fstdumxd.fsf@hotmail.com> <2021Oct27.231122@mips.complang.tuwien.ac.at>
<slgs05$7rf$1@dont-email.me> <2021Nov1.182821@mips.complang.tuwien.ac.at>
<slpo0e$34b$1@newsreader4.netcologne.de> <2021Nov2.094824@mips.complang.tuwien.ac.at>
<d71f0f03-ba1b-462c-bf7e-236003255918n@googlegroups.com> <2021Nov2.173551@mips.complang.tuwien.ac.at>
<sltddc$btq$1@dont-email.me> <2021Nov3.092521@mips.complang.tuwien.ac.at>
<sluebv$icv$1@dont-email.me> <4620d9be-e530-4dbf-8672-ca45bdb2f248n@googlegroups.com>
<2021Nov4.182748@mips.complang.tuwien.ac.at> <sm1ioa$h41$1@dont-email.me>
<ecac9895-c898-40bf-8733-c90a3c498712n@googlegroups.com> <sm1mgr$dt6$1@newsreader4.netcologne.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <826ad4e3-8b1f-4fdd-819d-e46647e30019n@googlegroups.com>
Subject: Re: Paper about ISO C
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Fri, 05 Nov 2021 00:11:47 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 99
 by: MitchAlsup - Fri, 5 Nov 2021 00:11 UTC

On Thursday, November 4, 2021 at 5:23:25 PM UTC-5, Thomas Koenig wrote:
> MitchAlsup <Mitch...@aol.com> schrieb:
> > From the comp.arch layer of understanding::
> ><
> > What is it that ISAs can do to minimize the space of UB ?
> We have discussed part of this before, but here is a bit
> of an expansion (and some repetition).
>
> There are tools to find undefined behavior (or erroneous programs),
> ranging from sanitizers (which add a low factor to execution time,
> maybe two or so) to really heavy-handed tools like valgrind which
> find a _lot_ of errors while making the code run abysmally slow.
>
> Think of ways that an ISA could be designed to speed up those tests.
> Zero overhead is almost certainly unreachable, but even reducing
> the speed overhead of checked code would help a lot.
>
> Going through the CERT coding standards, look for what can
> be implemented either efficiently or at zero cost. An example:
>
> 5.1 INT30-C. Ensure that unsigned integer operations do not wrap.
<
unsigned integers are the only integral format that has well defined
overflow characteristics == wrap. Why eliminate all wraps on the
only format that actually wraps correctly ?
<
For example: how does one check that
<
unsigned i = unsigned j -1
<
is different from:
<
unsigned i = unsigned j + 0xFFFFFFFFFFFFFFFFu
<
One is subtracting a very tiny negative number from j, the other is adding
a huge number to j that happens to have the same bit pattern as the tiny
subtrahend.
<
And why would one care ?
<
>
> Integer values must not be allowed to wrap, especially if they
> are used in any of the following ways:
<
signed integers are OVERFLOW checked.
conversions to signed integers are significance checked.
Should STs check significance in the parts that are not stored ?
>
> * Integer operands of any pointer arithmetic, including array
> indexing
<
AGEN exception or OVERFLOW exception depending on the instruction
at hand.
>
> * The assignment expression for the declaration of a variable
> length array
>
> * The postfix expression preceding square brackets [] or the
> expression in square brackets [] of a subscripted designation of
> an element of an array object
<
a+i is not allowed to OVERFLOW | AGEN:: check
>
> * Function arguments of type size_t or rsize_t (for example,
> an argument to a memory allocation function)
>
> * In security-critical code
>
> and they give the following example as a compliant solution:
>
> void func(unsigned int ui_a, unsigned int ui_b) {
> unsigned int usum;
> if (UINT_MAX - ui_a < ui_b) {
> /* Handle error */
> } else {
> usum = ui_a + ui_b;
> }
> /* ... */
> }
<
This seems to be a language expression limitation
<
void func(unsigned int ui_a, unsigned int ui_b) {
unsigned int usum, hsum;
{ hsum, usum } = ui_a+ui_b;
if( hsum )
{ it overflowed }
else
{ golden }
} >
> Also of interest are the chapters regarding arrays, characters
> and strings and memory management.
>
> In an ideal world, all checks would be zero overhead, so everybody
> would run every check all the time. Not likely to happen, though :-)
<
Checks are only zero overhead if you have the checks built into the ISA
ala:: descriptor machines. These machines have proven so slow as to
select themselves out of the high performance marketplace.

Re: Paper about ISO C

<sm1u6u$r68$1@dont-email.me>

  copy mid

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

  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: Paper about ISO C
Date: Thu, 4 Nov 2021 17:34:38 -0700
Organization: A noiseless patient Spider
Lines: 66
Message-ID: <sm1u6u$r68$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com>
<2021Nov2.094824@mips.complang.tuwien.ac.at>
<d71f0f03-ba1b-462c-bf7e-236003255918n@googlegroups.com>
<2021Nov2.173551@mips.complang.tuwien.ac.at> <sltddc$btq$1@dont-email.me>
<2021Nov3.092521@mips.complang.tuwien.ac.at> <sluebv$icv$1@dont-email.me>
<4620d9be-e530-4dbf-8672-ca45bdb2f248n@googlegroups.com>
<2021Nov4.182748@mips.complang.tuwien.ac.at> <sm1ioa$h41$1@dont-email.me>
<ecac9895-c898-40bf-8733-c90a3c498712n@googlegroups.com>
<2021Nov5.000057@mips.complang.tuwien.ac.at>
<26c1bc56-4e5c-4da5-a16f-3ee778478dccn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 5 Nov 2021 00:34:38 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="d7c210aade402baac0881ab94bfba818";
logging-data="27848"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+VK2n2LUpgKARsTX6fw+sI"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.2.1
Cancel-Lock: sha1:M9HyWKiAmQ+iijLSmNwrZvzlP6E=
In-Reply-To: <26c1bc56-4e5c-4da5-a16f-3ee778478dccn@googlegroups.com>
Content-Language: en-US
 by: Ivan Godard - Fri, 5 Nov 2021 00:34 UTC

On 11/4/2021 4:56 PM, MitchAlsup wrote:
> On Thursday, November 4, 2021 at 6:21:39 PM UTC-5, Anton Ertl wrote:
>> MitchAlsup <Mitch...@aol.com> writes:
>> >From the comp.arch layer of understanding::
>>> <
>>> What is it that ISAs can do to minimize the space of UB ?
>> Not sure what you mean by that, but let me answer "What can in ISA do
>> to make UB attractive (or less so)."
>>
>> The major reason why some people find undefined behaviour on integer
>> overflow so attractive is the fact that the decision to go with
>> I32LP64 requires sign-extending here and there with -fwrapv, e.g., with
>> loops like
>>
>> for (int i=0; i<n; i++)
>> r+=a[i];
>>
>> The address of a is 64 bits, but i is a signed 32-bit value, and needs
>> to be sign-extended with -fwrapv when forming a+i on every iteration
>> of the loop.
> <
> For a new ISA, why would anyone go with I32LP64 why not ILP64 ?

The Mill compiler is currently i32lp64 (though that may change). The
reason was data compatibility, primarily for arrays. There's a lot of
"int arr[n]" out there; "long arr[n]" not so much, and all the "foo *
[n]" have already been cleaned up in prior generations.

Sign and zero extending ops have almost been eliminated by Mill's
widening instructions (32 OP 32 -> 64 etc.) and mixed width address
arithmetic - remember Mill data has self-identifying width, so there's
no instruction explosion.

We decided a decade ago to set the clock at the 32-bit ALU boundary, and
rely on scheduling to hide the latency of 64 bit (and 128 bit)
instructions. They do hide quite well, but the HW state of the art has
progressed since that decision and probably it should be revisited; it's
a cheap change if warranted, as everything in there is spec driven anyway.

> <
> But why can 'n' not be checked for being "too big" before running the loop
> and avoid all of the a+i checking "in the loop". Here, the check seems easy
> enough (n>=0):: but it seems the real problem is that there is nothing close
> to the loop supplying the bounds for a[] !!?!
> <
>> If the instruction generated for i++ sign-extends (like
>> Alpha's addl, but then Alpha have a similar problem if i was defined
>> as unsigned; so we would need both sign-extending and zero-extending
>> variants), you don't need to sign-extend with an extra intruction.
> <
> In I32LP64 codes, Brian's My 66000 C compiler spits out copious
> quantities of EXT Rx,Rx,<31:0> // extract the lower 32 bits and sign
> extend.

About the only extend-type instructions we see are for code like
"int32_t a; int16_t b; a = b;" where people have used explicit irregular
sizes for API or memory reasons; they get "widen(...)" instructions. But
there phasing removes any cycle penalty:

load(@a); -> %load
....
widen(%load) -> %widen, store(@b, %widen);

So I assert that the business reasons for i32lp64 may be wrong, but
there's no technical reason not to use it in a new ISA.

Re: Paper about ISO C

<sm2jst$lhl$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!aioe.org!rd9pRsUZyxkRLAEK7e/Uzw.user.46.165.242.91.POSTED!not-for-mail
From: terje.ma...@tmsw.no (Terje Mathisen)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Fri, 5 Nov 2021 07:44:44 +0100
Organization: Aioe.org NNTP Server
Message-ID: <sm2jst$lhl$1@gioia.aioe.org>
References: <87fstdumxd.fsf@hotmail.com>
<2021Oct27.231122@mips.complang.tuwien.ac.at> <slgs05$7rf$1@dont-email.me>
<2021Nov1.182821@mips.complang.tuwien.ac.at>
<slpo0e$34b$1@newsreader4.netcologne.de>
<2021Nov2.094824@mips.complang.tuwien.ac.at>
<d71f0f03-ba1b-462c-bf7e-236003255918n@googlegroups.com>
<2021Nov2.173551@mips.complang.tuwien.ac.at> <sltddc$btq$1@dont-email.me>
<2021Nov3.092521@mips.complang.tuwien.ac.at> <sluebv$icv$1@dont-email.me>
<4620d9be-e530-4dbf-8672-ca45bdb2f248n@googlegroups.com>
<2021Nov4.182748@mips.complang.tuwien.ac.at> <sm1ioa$h41$1@dont-email.me>
<ecac9895-c898-40bf-8733-c90a3c498712n@googlegroups.com>
<sm1mgr$dt6$1@newsreader4.netcologne.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="22069"; posting-host="rd9pRsUZyxkRLAEK7e/Uzw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101
Firefox/60.0 SeaMonkey/2.53.9.1
X-Notice: Filtered by postfilter v. 0.9.2
 by: Terje Mathisen - Fri, 5 Nov 2021 06:44 UTC

Thomas Koenig wrote:
> MitchAlsup <MitchAlsup@aol.com> schrieb:
>
>> From the comp.arch layer of understanding::
>> <
>> What is it that ISAs can do to minimize the space of UB ?
>
> We have discussed part of this before, but here is a bit
> of an expansion (and some repetition).
>
> There are tools to find undefined behavior (or erroneous programs),
> ranging from sanitizers (which add a low factor to execution time,
> maybe two or so) to really heavy-handed tools like valgrind which
> find a _lot_ of errors while making the code run abysmally slow.
>
> Think of ways that an ISA could be designed to speed up those tests.
> Zero overhead is almost certainly unreachable, but even reducing
> the speed overhead of checked code would help a lot.
>
> Going through the CERT coding standards, look for what can
> be implemented either efficiently or at zero cost. An example:
>
> 5.1 INT30-C. Ensure that unsigned integer operations do not wrap.
>
> Integer values must not be allowed to wrap, especially if they
> are used in any of the following ways:
>
> * Integer operands of any pointer arithmetic, including array
> indexing
>
> * The assignment expression for the declaration of a variable
> length array
>
> * The postfix expression preceding square brackets [] or the
> expression in square brackets [] of a subscripted designation of
> an element of an array object
>
> * Function arguments of type size_t or rsize_t (for example,
> an argument to a memory allocation function)
>
> * In security-critical code

Those are all very reasonable.

>
> and they give the following example as a compliant solution:
>
> void func(unsigned int ui_a, unsigned int ui_b) {
> unsigned int usum;
> if (UINT_MAX - ui_a < ui_b) {
> /* Handle error */
> } else {
> usum = ui_a + ui_b;
> }
> /* ... */
> }

When you have already taken the trouble to make both arguments unsigned,
then I'd prefer to use a simpler form:

void func(unsigned int ui_a, unsigned int ui_b) {
unsigned int usum = ui_a + ui_b; // Can wrap but not fault
if (usum < ui_b) { // check for wrapping
/* Handle error */
}
/* do whatever with usum */
/* ... */
}

>
> Also of interest are the chapters regarding arrays, characters
> and strings and memory management.
>
> In an ideal world, all checks would be zero overhead, so everybody
> would run every check all the time. Not likely to happen, though :-)
>
Running checks everywhere except inside innermost loops, by first
verifying that the loop itself cannot fault, has very close to zero
actual overhead, as proven by modern Java/Kotlin/etc compilers.

(I'm not sure if Rust gives similar guarantees, but I believe you can
get the same effect there?)

Terje

--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

Re: Paper about ISO C

<sm2kav$pub$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!aioe.org!rd9pRsUZyxkRLAEK7e/Uzw.user.46.165.242.91.POSTED!not-for-mail
From: terje.ma...@tmsw.no (Terje Mathisen)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Fri, 5 Nov 2021 07:52:14 +0100
Organization: Aioe.org NNTP Server
Message-ID: <sm2kav$pub$1@gioia.aioe.org>
References: <87fstdumxd.fsf@hotmail.com>
<2021Nov2.094824@mips.complang.tuwien.ac.at>
<d71f0f03-ba1b-462c-bf7e-236003255918n@googlegroups.com>
<2021Nov2.173551@mips.complang.tuwien.ac.at> <sltddc$btq$1@dont-email.me>
<2021Nov3.092521@mips.complang.tuwien.ac.at> <sluebv$icv$1@dont-email.me>
<4620d9be-e530-4dbf-8672-ca45bdb2f248n@googlegroups.com>
<2021Nov4.182748@mips.complang.tuwien.ac.at> <sm1ioa$h41$1@dont-email.me>
<ecac9895-c898-40bf-8733-c90a3c498712n@googlegroups.com>
<2021Nov5.000057@mips.complang.tuwien.ac.at>
<26c1bc56-4e5c-4da5-a16f-3ee778478dccn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="26571"; posting-host="rd9pRsUZyxkRLAEK7e/Uzw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101
Firefox/60.0 SeaMonkey/2.53.9.1
X-Notice: Filtered by postfilter v. 0.9.2
 by: Terje Mathisen - Fri, 5 Nov 2021 06:52 UTC

MitchAlsup wrote:
> But I was wondering more about doing things like::
> <
> int a >> int b; // where b is allowed to be negative
> int a << int b; // where b is allowed to be negative
> <
> And when a shift count is negative, the shift is performed in the "other" direction.
>

I have been in that situation a few times, i.e. wanting/needing
potentially reverse shift direction, but it has always been possible to
bias my variables so as to make it unnecessary, with zero or
single-cycle overhead cost.

Terje
--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

Re: Paper about ISO C

<2021Nov5.080856@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!aioe.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: Paper about ISO C
Date: Fri, 05 Nov 2021 07:08:56 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 84
Message-ID: <2021Nov5.080856@mips.complang.tuwien.ac.at>
References: <87fstdumxd.fsf@hotmail.com> <2021Nov2.173551@mips.complang.tuwien.ac.at> <sltddc$btq$1@dont-email.me> <2021Nov3.092521@mips.complang.tuwien.ac.at> <sluebv$icv$1@dont-email.me> <4620d9be-e530-4dbf-8672-ca45bdb2f248n@googlegroups.com> <2021Nov4.182748@mips.complang.tuwien.ac.at> <sm1ioa$h41$1@dont-email.me> <ecac9895-c898-40bf-8733-c90a3c498712n@googlegroups.com> <2021Nov5.000057@mips.complang.tuwien.ac.at> <26c1bc56-4e5c-4da5-a16f-3ee778478dccn@googlegroups.com>
Injection-Info: reader02.eternal-september.org; posting-host="6abc18676fb7eef525c47edc1fbe1446";
logging-data="23986"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1895IXuscPqgl9JHzD2jyRh"
Cancel-Lock: sha1:0hhf7HWvqD1ZtgkyFwP0Gh5U7j0=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Fri, 5 Nov 2021 07:08 UTC

MitchAlsup <MitchAlsup@aol.com> writes:
>On Thursday, November 4, 2021 at 6:21:39 PM UTC-5, Anton Ertl wrote:
>> MitchAlsup <Mitch...@aol.com> writes:
>> >From the comp.arch layer of understanding::
>> ><
>> >What is it that ISAs can do to minimize the space of UB ?
>> Not sure what you mean by that, but let me answer "What can in ISA do
>> to make UB attractive (or less so)."
>>
>> The major reason why some people find undefined behaviour on integer
>> overflow so attractive is the fact that the decision to go with
>> I32LP64 requires sign-extending here and there with -fwrapv, e.g., with
>> loops like
>>
>> for (int i=0; i<n; i++)
>> r+=a[i];
>>
>> The address of a is 64 bits, but i is a signed 32-bit value, and needs
>> to be sign-extended with -fwrapv when forming a+i on every iteration
>> of the loop.
><
>For a new ISA, why would anyone go with I32LP64 why not ILP64 ?

Yes, indeed, although you should have asked (and maybe have asked) the
question 30 years ago when MIPS was extended to 64 bits and Alpha was
introduced. By now, I32LP64 is established, and everybody else (e.g.,
AMD in 2003, ARM and RISC-V in the 2010s) sticks to it to make it easy
to port existing software to the architecture. The cost is the large
number of sign and zero extends that is necessary in some form or
other (and some of the sign extends are "optimized" away by assuming
that signed overflow does not happen).

>But why can 'n' not be checked for being "too big" before running the loop
>and avoid all of the a+i checking "in the loop". Here, the check seems easy
>enough (n>=0):: but it seems the real problem is that there is nothing close
>to the loop supplying the bounds for a[] !!?!

Yes, it should be possible to make do with zero-extending here (which
AMD64 does for free). I looked up the example that [wang+12] gave:

int k;
int *ic, *is;
....
for(k = 1; k <= M; k++) {
...
ic[k] += is[k];
...
}

This is a loop from 456.hmmer, and both gcc and clang sign-extended k
after the k++ here if -fwrapv was used (and left away the sign
extension by default). Here, too, sign extension can be eliminated
without assuming that k++ does not overflow, by transforming the loop into:

for(k = 0; k < M; k++) {
...
(ic+1)[k] += (is+1)[k];
...
}

But back to your question: You can avoid burdening the compiler with
such optimizations or with assuming that overflow does not happen by
making the sign extension free.

>But I was wondering more about doing things like::
><
> int a >> int b; // where b is allowed to be negative
> int a << int b; // where b is allowed to be negative
><
>And when a shift count is negative, the shift is performed in the "other" direction.

I think divergent behaviour between architectures for instructions
that would be used for implementing a specific programming language
construct is one of the reasons for not defining behaviour (in
particular if one of the behaviours is to trap).

OTOH, convergent behaviour that programming language designers don't
want to specify (like "a << b" is equivalent to "a << (b&63)") is
another reason.

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

Re: Paper about ISO C

<iuk8caFcpnoU1@mid.individual.net>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: niklas.h...@tidorum.invalid (Niklas Holsti)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Fri, 5 Nov 2021 10:30:02 +0200
Organization: Tidorum Ltd
Lines: 53
Message-ID: <iuk8caFcpnoU1@mid.individual.net>
References: <87fstdumxd.fsf@hotmail.com> <slgs05$7rf$1@dont-email.me>
<2021Nov1.182821@mips.complang.tuwien.ac.at>
<slpo0e$34b$1@newsreader4.netcologne.de>
<2021Nov2.094824@mips.complang.tuwien.ac.at>
<d71f0f03-ba1b-462c-bf7e-236003255918n@googlegroups.com>
<2021Nov2.173551@mips.complang.tuwien.ac.at> <sltddc$btq$1@dont-email.me>
<2021Nov3.092521@mips.complang.tuwien.ac.at> <867ddoej5h.fsf@linuxsc.com>
<2021Nov4.082756@mips.complang.tuwien.ac.at> <86lf24c6nq.fsf@linuxsc.com>
<2021Nov4.181746@mips.complang.tuwien.ac.at> <86h7crdcr6.fsf@linuxsc.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net 23TVxFeYbblbP1LIHT0WYAJz9eA4d+MbFBZmr3e5q+IOTHi05e
Cancel-Lock: sha1:dA8S3fQAHaSwXXwDPWKfmJeQFeA=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0)
Gecko/20100101 Thunderbird/78.14.0
In-Reply-To: <86h7crdcr6.fsf@linuxsc.com>
Content-Language: en-US
 by: Niklas Holsti - Fri, 5 Nov 2021 08:30 UTC

On 2021-11-04 19:58, Tim Rentsch wrote:
> anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>
>> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>>
>>> anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>>>
>>>> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>>>>
>>>>> anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>>>>>
>>>>>> Standard C is such a programming language; it only specifies
>>>>>> how "strictly conforming programs" should behave, [...]
>>>>>
>>>>> That statement is patently false.
>>>>
>>>> Please tell us where the C standard specifies how, e.g., the
>>>> following program should behave:
>>>>
>>>> int main() {
>>>> return 0;
>>>> }
>>>
>>> First let me ask a question. Do you think there's a difference
>>> between that program and this one:
>>>
>>> int main(void) {
>>> return 0;
>>> }
>>
>> I would not expect a difference, but in any case, the arguments of
>> main() are not the point of this example. Choose whatever arguments
>> you want to provide an answer for. The result is not a "strictly
>> conforming program" in any case, because it terminates.
>
> What makes you think strictly conforming programs cannot
> terminate?

Anton has not yet answered that, but I suspect that the reason is that a
strictly conforming program "shall not produce output dependent on any
unspecified, undefined, or _implementation-defined_ behavior", but when
the main() function returns 0, this is the same as calling exit(0),
which means that "control is returned to the host environment [with] an
_implementation-defined_ form of the status /successful termination/".
(Quotes from the C11 draft N1570, with my addition of emphasis.)

However, IMO, returning to the host environment is not "producing
output", so IMO it cannot violate the strict conformance rules. I think
the words "an implementation-defined form of" could be omitted from the
second quotation above; it would be enough for the C standard to specify
that a "successful termination" status is returned to the environment,
without saying anything about how that status is represented.

Re: Paper about ISO C

<2021Nov5.102347@mips.complang.tuwien.ac.at>

  copy mid

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

  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: Paper about ISO C
Date: Fri, 05 Nov 2021 09:23:47 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 36
Message-ID: <2021Nov5.102347@mips.complang.tuwien.ac.at>
References: <87fstdumxd.fsf@hotmail.com> <sltddc$btq$1@dont-email.me> <2021Nov3.092521@mips.complang.tuwien.ac.at> <sluebv$icv$1@dont-email.me> <4620d9be-e530-4dbf-8672-ca45bdb2f248n@googlegroups.com> <2021Nov4.182748@mips.complang.tuwien.ac.at> <sm1ioa$h41$1@dont-email.me> <ecac9895-c898-40bf-8733-c90a3c498712n@googlegroups.com> <2021Nov5.000057@mips.complang.tuwien.ac.at> <26c1bc56-4e5c-4da5-a16f-3ee778478dccn@googlegroups.com> <2021Nov5.080856@mips.complang.tuwien.ac.at>
Injection-Info: reader02.eternal-september.org; posting-host="6abc18676fb7eef525c47edc1fbe1446";
logging-data="27977"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/jNw5HoRUQT3rxTAhrMNAz"
Cancel-Lock: sha1:EDIcDnXACZW11nzRt3uhaYd7dag=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Fri, 5 Nov 2021 09:23 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>I looked up the example that [wang+12] gave:
>
>int k;
>int *ic, *is;
>...
>for(k = 1; k <= M; k++) {
> ...
> ic[k] += is[k];
> ...
>}
>
>This is a loop from 456.hmmer, and both gcc and clang sign-extended k
>after the k++ here if -fwrapv was used (and left away the sign
>extension by default).

BTW, this is the only place in SPECint 2006 where -fwrapv makes a
noticable differene [wang+12].

And here's the reference I forgot to include:

@InProceedings{wang+12,
author = {Xi Wang and Haogang Chen and Alvin Cheung and Zhihao Jia and Nickolai Zeldovich and M. Frans Kaashoek},
title = {Undefined Behavior: What Happened to My Code?},
booktitle = {Asia-Pacific Workshop on Systems (APSYS'12)},
OPTpages = {},
year = {2012},
url1 = {http://homes.cs.washington.edu/~akcheung/getFile.php?file=apsys12.pdf},
url2 = {http://people.csail.mit.edu/nickolai/papers/wang-undef-2012-08-21.pdf},
OPTannote = {}
}

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

Re: Paper about ISO C

<2021Nov5.103521@mips.complang.tuwien.ac.at>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!paganini.bofh.team!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: Paper about ISO C
Date: Fri, 05 Nov 2021 09:35:21 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 64
Message-ID: <2021Nov5.103521@mips.complang.tuwien.ac.at>
References: <87fstdumxd.fsf@hotmail.com> <slpo0e$34b$1@newsreader4.netcologne.de> <2021Nov2.094824@mips.complang.tuwien.ac.at> <d71f0f03-ba1b-462c-bf7e-236003255918n@googlegroups.com> <2021Nov2.173551@mips.complang.tuwien.ac.at> <sltddc$btq$1@dont-email.me> <2021Nov3.092521@mips.complang.tuwien.ac.at> <867ddoej5h.fsf@linuxsc.com> <2021Nov4.082756@mips.complang.tuwien.ac.at> <86lf24c6nq.fsf@linuxsc.com> <2021Nov4.181746@mips.complang.tuwien.ac.at> <86h7crdcr6.fsf@linuxsc.com>
Injection-Info: reader02.eternal-september.org; posting-host="6abc18676fb7eef525c47edc1fbe1446";
logging-data="27977"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18digrGW86IgDOGoTHSPtA2"
Cancel-Lock: sha1:v5f1i29mGQjO/ldIhYMT95PEwEw=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Fri, 5 Nov 2021 09:35 UTC

Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>
>> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>>
>>> anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>>>
>>>> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>>>>
>>>>> anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>>>>>
>>>>>> Standard C is such a programming language; it only specifies
>>>>>> how "strictly conforming programs" should behave, [...]
>>>>>
>>>>> That statement is patently false.
>>>>
>>>> Please tell us where the C standard specifies how, e.g., the
>>>> following program should behave:
>>>>
>>>> int main() {
>>>> return 0;
>>>> }
>>>
>>> First let me ask a question. Do you think there's a difference
>>> between that program and this one:
>>>
>>> int main(void) {
>>> return 0;
>>> }
>>
>> I would not expect a difference, but in any case, the arguments of
>> main() are not the point of this example. Choose whatever arguments
>> you want to provide an answer for. The result is not a "strictly
>> conforming program" in any case, because it terminates.
>
>What makes you think strictly conforming programs cannot
>terminate?

7.22.4.4 in n1570 says:

|Finally, control is returned to the host environment. If the value of
|status is zero or EXIT_SUCCESS, an implementation-defined form of the
|status successful termination is returned. If the value of status is
|EXIT_FAILURE, an implementation-defined form of the status
|unsuccessful termination is returned. Otherwise the status returned
|is implementation-defined.

All other ways to terminate C programs eventually do this.

WRT my original statement, this means that the C standard does not
specify how the program behaves.

You claimed that my statement is "patently false". Please support
your position.

It seems to me that my statement is a trivial consequence of the
definition of a "strictly conforming program", and is therefore
patently true, but if you have a good argument to the contrary, please
elucidate us.

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

Re: Paper about ISO C

<2021Nov5.115649@mips.complang.tuwien.ac.at>

  copy mid

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

  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: Paper about ISO C
Date: Fri, 05 Nov 2021 10:56:49 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 30
Distribution: world
Message-ID: <2021Nov5.115649@mips.complang.tuwien.ac.at>
References: <87fstdumxd.fsf@hotmail.com> <slc6kj$vv9$1@newsreader4.netcologne.de> <2021Oct27.231122@mips.complang.tuwien.ac.at> <slgs05$7rf$1@dont-email.me> <2021Nov1.182821@mips.complang.tuwien.ac.at> <slpo0e$34b$1@newsreader4.netcologne.de> <2021Nov2.094824@mips.complang.tuwien.ac.at> <d71f0f03-ba1b-462c-bf7e-236003255918n@googlegroups.com> <2021Nov2.173551@mips.complang.tuwien.ac.at> <sltddc$btq$1@dont-email.me> <2021Nov3.092521@mips.complang.tuwien.ac.at> <sm18dn$2p0$1@newsreader4.netcologne.de>
Injection-Info: reader02.eternal-september.org; posting-host="6abc18676fb7eef525c47edc1fbe1446";
logging-data="11171"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/DPi7OGqpRa0c5qLSk5tIR"
Cancel-Lock: sha1:EzRvp7pcuGjoPNAlBHAPV6Tj29k=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Fri, 5 Nov 2021 10:56 UTC

Thomas Koenig <tkoenig@netcologne.de> writes:
>Anton Ertl <anton@mips.complang.tuwien.ac.at> schrieb:
>
>> My position is basically that a responsible maintainer for a
>> widely-used compiler does not break existing source code
>
>Question: You mentioned tail call optimization in one of
>your posts.
>
>Should compilers be mandated to copy arguments for
>
>int bar (int a, int b, int c);
>
>int foo(int a, int b, int c)
>{
> if (a > 0)
> return bar(a,b,c);
> else
> return -1;
>}

I don't see why. I also don't see the connection to tail-call
optimization. On AMD64 gcc -O does not copy arguments, whether you
enable tail-call optimization in this case (and in this case it
happens to work) with -foptimize-sibling-calls or not.

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

Re: Paper about ISO C

<ea8a8c64-1e97-49bd-b78f-97763fd96de9n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:6214:c81:: with SMTP id r1mr56499416qvr.31.1636111912560;
Fri, 05 Nov 2021 04:31:52 -0700 (PDT)
X-Received: by 2002:a9d:7615:: with SMTP id k21mr10680522otl.38.1636111912297;
Fri, 05 Nov 2021 04:31:52 -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: Fri, 5 Nov 2021 04:31:52 -0700 (PDT)
In-Reply-To: <2021Nov5.080856@mips.complang.tuwien.ac.at>
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> <2021Nov2.173551@mips.complang.tuwien.ac.at>
<sltddc$btq$1@dont-email.me> <2021Nov3.092521@mips.complang.tuwien.ac.at>
<sluebv$icv$1@dont-email.me> <4620d9be-e530-4dbf-8672-ca45bdb2f248n@googlegroups.com>
<2021Nov4.182748@mips.complang.tuwien.ac.at> <sm1ioa$h41$1@dont-email.me>
<ecac9895-c898-40bf-8733-c90a3c498712n@googlegroups.com> <2021Nov5.000057@mips.complang.tuwien.ac.at>
<26c1bc56-4e5c-4da5-a16f-3ee778478dccn@googlegroups.com> <2021Nov5.080856@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ea8a8c64-1e97-49bd-b78f-97763fd96de9n@googlegroups.com>
Subject: Re: Paper about ISO C
From: already5...@yahoo.com (Michael S)
Injection-Date: Fri, 05 Nov 2021 11:31:52 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 94
 by: Michael S - Fri, 5 Nov 2021 11:31 UTC

On Friday, November 5, 2021 at 9:39:02 AM UTC+2, Anton Ertl wrote:
> MitchAlsup <Mitch...@aol.com> writes:
> >On Thursday, November 4, 2021 at 6:21:39 PM UTC-5, Anton Ertl wrote:
> >> MitchAlsup <Mitch...@aol.com> writes:
> >> >From the comp.arch layer of understanding::
> >> ><
> >> >What is it that ISAs can do to minimize the space of UB ?
> >> Not sure what you mean by that, but let me answer "What can in ISA do
> >> to make UB attractive (or less so)."
> >>
> >> The major reason why some people find undefined behaviour on integer
> >> overflow so attractive is the fact that the decision to go with
> >> I32LP64 requires sign-extending here and there with -fwrapv, e.g., with
> >> loops like
> >>
> >> for (int i=0; i<n; i++)
> >> r+=a[i];
> >>
> >> The address of a is 64 bits, but i is a signed 32-bit value, and needs
> >> to be sign-extended with -fwrapv when forming a+i on every iteration
> >> of the loop.
> ><
> >For a new ISA, why would anyone go with I32LP64 why not ILP64 ?
> Yes, indeed, although you should have asked (and maybe have asked) the
> question 30 years ago when MIPS was extended to 64 bits and Alpha was
> introduced. By now, I32LP64 is established, and everybody else (e.g.,
> AMD in 2003, ARM and RISC-V in the 2010s) sticks to it to make it easy
> to port existing software to the architecture. The cost is the large
> number of sign and zero extends that is necessary in some form or
> other (and some of the sign extends are "optimized" away by assuming
> that signed overflow does not happen).
> >But why can 'n' not be checked for being "too big" before running the loop
> >and avoid all of the a+i checking "in the loop". Here, the check seems easy
> >enough (n>=0):: but it seems the real problem is that there is nothing close
> >to the loop supplying the bounds for a[] !!?!
> Yes, it should be possible to make do with zero-extending here (which
> AMD64 does for free). I looked up the example that [wang+12] gave:
>
> int k;
> int *ic, *is;
> ...
> for(k = 1; k <= M; k++) {
> ...
> ic[k] += is[k];
> ...
> }
>
> This is a loop from 456.hmmer, and both gcc and clang sign-extended k
> after the k++ here if -fwrapv was used (and left away the sign
> extension by default). Here, too, sign extension can be eliminated
> without assuming that k++ does not overflow, by transforming the loop into:
>
> for(k = 0; k < M; k++) {
> ...
> (ic+1)[k] += (is+1)[k];
> ...
> }
>
> But back to your question: You can avoid burdening the compiler with
> such optimizations or with assuming that overflow does not happen by
> making the sign extension free.

You mean, making the sign extension free in part of the code that generates effective address?
So, on architectures similar to x86/Arm/PPC/SPARC you advocate addressing mode
that calculates EA=signExt64(RegI32)*SzImm+RegB64 ?
And on architectures similar to MIPS64/RV64/Alpha you advocate ALU instruction that does the same?
Supposedly, with SzImm that can be 1,2,4,8 and hopefully 16, 32, 64 ?

But that would not help more general case of iterating array of items that have size not equal to small power-of-two.
Even if your ISA provided implied sign-extension option for Integer multiply,
the resulting code would at best match UB-based code generator by number of instructions and
even that is not given.
It's unlikely to match its speed, because integer multiplication tends to be slower than addition.

Personally, to bypass the problem, I am starting to acquire the habit of defining (in performance-critical loops)
such variables as 'i' in your example as ptrdiff_t.

> >But I was wondering more about doing things like::
> ><
> > int a >> int b; // where b is allowed to be negative
> > int a << int b; // where b is allowed to be negative
> ><
> >And when a shift count is negative, the shift is performed in the "other" direction.
> I think divergent behaviour between architectures for instructions
> that would be used for implementing a specific programming language
> construct is one of the reasons for not defining behaviour (in
> particular if one of the behaviours is to trap).
>
> OTOH, convergent behaviour that programming language designers don't
> want to specify (like "a << b" is equivalent to "a << (b&63)") is
> another reason.
> - anton
> --
> 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
> Mitch Alsup, <c17fcd89-f024-40e7...@googlegroups.com>

Re: Paper about ISO C

<sm3cl6$ij0$1@dont-email.me>

  copy mid

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

  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: Paper about ISO C
Date: Fri, 5 Nov 2021 14:47:17 +0100
Organization: A noiseless patient Spider
Lines: 102
Message-ID: <sm3cl6$ij0$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com> <slatma$8au$1@dont-email.me>
<2021Oct27.193426@mips.complang.tuwien.ac.at>
<slc6kj$vv9$1@newsreader4.netcologne.de>
<2021Oct27.231122@mips.complang.tuwien.ac.at> <slgs05$7rf$1@dont-email.me>
<2021Nov1.182821@mips.complang.tuwien.ac.at>
<slpo0e$34b$1@newsreader4.netcologne.de>
<2021Nov2.094824@mips.complang.tuwien.ac.at>
<d71f0f03-ba1b-462c-bf7e-236003255918n@googlegroups.com>
<2021Nov2.173551@mips.complang.tuwien.ac.at> <sltddc$btq$1@dont-email.me>
<2021Nov3.092521@mips.complang.tuwien.ac.at> <sluebv$icv$1@dont-email.me>
<sm0050$109j$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 5 Nov 2021 13:47:18 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="1024cedc26d9bb73e7d8ce5e94eb7aa4";
logging-data="19040"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+2TxHrIQn2rrnYR2VJuP6Z83f+gT3Vnqw="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:gE9L9Pek07LLqb3hj2h11GxlPFY=
In-Reply-To: <sm0050$109j$1@gioia.aioe.org>
Content-Language: en-GB
 by: David Brown - Fri, 5 Nov 2021 13:47 UTC

On 04/11/2021 07:55, Terje Mathisen wrote:
> David Brown wrote:
>> On 03/11/2021 09:25, Anton Ertl wrote:
>>> David Brown <david.brown@hesbynett.no> writes:
>>>> On 02/11/2021 17:35, Anton Ertl wrote:
>>>>> Which leads us back
>>>>> to the #1 advantage that manual optimization has over compilers:
>>>>> requirements instead of source code equivalence.
>>>>>
>>>>
>>>> I think we all know that is something programmers can do that compilers
>>>> cannot.  I'm not sure why you feel the need to emphasise it so often -
>>>> are you under the impression that some people think compilers read
>>>> programmers' minds to learn information not expressed in the source
>>>> code?
>>>
>>> There is a widespread myth that compilers are so good at optimization
>>> that there is no point for programmers to think about optimization
>>> (with some variations; e.g., selecting a good algorithm is admitted as
>>> being outside of the realm of compilers, if algorithms are discussed
>>> at all).
>>
>> Compiler optimisation does a lot of things well, and understanding this
>> can let you write code in a clearer, safer and more maintainable fashion
>> with less programmer effort and more efficient results.  Compilers also
>> know a lot more details about the target architecture and its timings
>> than the great majority of programmers.  Failing to understand this, or
>> failing to use good tools in a good way, means more manual work and
>> sometimes manual "micro-optimisations" that are actually
>> counter-productive in practice.
>
> This is both correct, and misleading:
>
> Yes, compilers do know a lot more about the nooks & crannies of cpu
> performance than the vast majority of programmers, but OTOH, the type of
> optimizations you have to employ to handle micro-architectural balance
> shifts can very often be far larger than anything a compiler would be
> allowed to do.
>

There are some a compiler can do, some that they can't, and some that
modern compilers can help with if you work with them. Compilers can,
for example, intersperse different kinds of instructions or use
different registers to reduce pipeline stalls or bottlenecks. They can
/sometimes/ make use of SIMD and vector instructions, but often they do
this best if you use extension features such as vector types. They can
rarely make use of the more complicated processor instructions for SIMD,
hash acceleration, etc.

> A case in point: I have done several conference presentations and a
> university guest lecture on a single program/algorithm (unix wc - word
> count) which I've optimized for most generations of x86 cpus from 8088
> to Pentium and PentiumPro.
>
> The type of optimizations needed consisted of total rewrites, using new
> algorithms, but still achieving the same end result.
>

Compilers only know "tricks" that their developers have programmed.

> None of those rewrites will ever become possible for any compiler I can
> imagine, besides the fact that most of them was written in pure asm to
> be able to control everything. I did have C or Pascal equivalents though.
>

The aim of C and good compilers here is not to replace the programmer
who figures out the most efficient algorithms, but to reduce the need to
use assembly to implement them efficiently. (And that's "reduce", not
"replace" - it's always an ongoing process.)

> The main steps were (8088) unrolled in-word and white space scanners,
> with absolute minimum code and data byte counts, via runtime-generated
> state machines carefully located at all 128-byte boundaries of a 64K
> segment) (similar to direct threaded forth) that would load the next
> input byte and use that as the high part of a direct branch address,
> with the lower 8 bits containing either 0 or 128 to indicate the current
> in-word status, then around the Pentium time frame I switched to a pure
> data state machine where the code had no branches at all when processing
> a block of 256 input bytes.
>
> For the Out-of-Order class machines (PentiumPro etc) most of the code
> has both C and asm versions, I have a bunch (6-8?) different
> implementations and pick the best at runtime by benchmarking all of them
> against the first 4K block of input.
>
> Somewhat coincidentally, those final versions tend to produce very near
> asm-speed results for the C implementations since there is no need to
> trick the compiler into generating the code I need.
>

If you feel you need to "trick" the compiler, the results will be
fragile - you will not be able to rely on the same details in the object
code for different versions of the compiler, different flags, different
compilers, different targets. Of course, not all code needs to be
widely portable - indeed, most code written has very little need of
portability. But if you are able to get code expressed in correct and
fairly portable C, and you get close to optimal results when you compile
it, then you have something a lot more useful than hand-written
assembly. You no longer have to start again for each new generation of
chip, or each new architecture.

Re: Paper about ISO C

<sm3fgd$8jq$1@dont-email.me>

  copy mid

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

  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: Paper about ISO C
Date: Fri, 5 Nov 2021 15:35:57 +0100
Organization: A noiseless patient Spider
Lines: 45
Message-ID: <sm3fgd$8jq$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com>
<2021Oct27.231122@mips.complang.tuwien.ac.at> <slgs05$7rf$1@dont-email.me>
<2021Nov1.182821@mips.complang.tuwien.ac.at>
<slpo0e$34b$1@newsreader4.netcologne.de>
<2021Nov2.094824@mips.complang.tuwien.ac.at>
<d71f0f03-ba1b-462c-bf7e-236003255918n@googlegroups.com>
<2021Nov2.173551@mips.complang.tuwien.ac.at> <sltddc$btq$1@dont-email.me>
<2021Nov3.092521@mips.complang.tuwien.ac.at> <sluebv$icv$1@dont-email.me>
<4620d9be-e530-4dbf-8672-ca45bdb2f248n@googlegroups.com>
<2021Nov4.182748@mips.complang.tuwien.ac.at> <sm1ioa$h41$1@dont-email.me>
<ecac9895-c898-40bf-8733-c90a3c498712n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 5 Nov 2021 14:35:57 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="1024cedc26d9bb73e7d8ce5e94eb7aa4";
logging-data="8826"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19xUu6gRj4T4Hi4DW1r2fAVz/duZLKz83M="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:uytlHs4wBwrHKehHXJjw+SunkbU=
In-Reply-To: <ecac9895-c898-40bf-8733-c90a3c498712n@googlegroups.com>
Content-Language: en-GB
 by: David Brown - Fri, 5 Nov 2021 14:35 UTC

On 04/11/2021 22:45, MitchAlsup wrote:
> On Thursday, November 4, 2021 at 4:19:08 PM UTC-5, David Brown wrote:

>>
>> I know that's not what you were thinking of - but that is what you said.
>> This is why I am so strongly against your ideas about consistency and
>> undefined behaviour - your statements are so sweeping that they cover
>> things that are clearly ridiculous. If you want to pick /specific/
>> classes of UB and give /specific/ definitions to how you want those to
>> behave, then we can get somewhere. I might not agree that the new
>> semantics you pick are an improvement (or not an improvement for my own
>> use), but I will happily appreciate that people might want to add new
>> semantics to the language.
> <
> From the comp.arch layer of understanding::
> <
> What is it that ISAs can do to minimize the space of UB ?
>

That's a different kind of question, and more in line with what I think
is a feasible direction for discussion. Again, I might not agree that
it is desirable to reduce a particular type of UB - but I can see that
some people might want to define semantics for specific classes of UB.

For example, it would be a simple matter to define the semantics for
signed integer overflow - and some people, but by no means all people,
would see that as useful.

It is highly impractical to define the semantics for what happens when
you try to write to an object defined as "const". (I gather some old
FORTRAN compilers let you accidentally redefine the values of integer
constants.) It is impossible to define the semantics for what happens
if a function is defined in one unit with one set of parameters, and
called from a different unit with a different set of parameters.

And several things that are left as UB in the C standards could clearly
be detected by the toolchain. Often they /are/ detected and diagnosed
by the toolchain, but it could be nice to make this a requirement in the
standards rather than UB.

Compilers and their targets are always free to give additional semantics
to things that are UB in the C standards. An ISA could have a hardware
exception any time address 0 is accessed - and the compiler could
support that feature.

Re: Paper about ISO C

<sm3g5b$ddu$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Fri, 5 Nov 2021 15:47:07 +0100
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <sm3g5b$ddu$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com>
<2021Oct27.231122@mips.complang.tuwien.ac.at> <slgs05$7rf$1@dont-email.me>
<2021Nov1.182821@mips.complang.tuwien.ac.at>
<slpo0e$34b$1@newsreader4.netcologne.de>
<2021Nov2.094824@mips.complang.tuwien.ac.at>
<d71f0f03-ba1b-462c-bf7e-236003255918n@googlegroups.com>
<2021Nov2.173551@mips.complang.tuwien.ac.at> <sltddc$btq$1@dont-email.me>
<2021Nov3.092521@mips.complang.tuwien.ac.at> <sluebv$icv$1@dont-email.me>
<4620d9be-e530-4dbf-8672-ca45bdb2f248n@googlegroups.com>
<2021Nov4.182748@mips.complang.tuwien.ac.at> <sm1ioa$h41$1@dont-email.me>
<ecac9895-c898-40bf-8733-c90a3c498712n@googlegroups.com>
<sm1mgr$dt6$1@newsreader4.netcologne.de>
<826ad4e3-8b1f-4fdd-819d-e46647e30019n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 5 Nov 2021 14:47:08 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="1024cedc26d9bb73e7d8ce5e94eb7aa4";
logging-data="13758"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/l5S+6mXb6gzhMxxN/2f2Mj08Z/FlMZy8="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:l9GeXPoFHx9OlvdFMuBISsRDo9o=
In-Reply-To: <826ad4e3-8b1f-4fdd-819d-e46647e30019n@googlegroups.com>
Content-Language: en-GB
 by: David Brown - Fri, 5 Nov 2021 14:47 UTC

On 05/11/2021 01:11, MitchAlsup wrote:
> On Thursday, November 4, 2021 at 5:23:25 PM UTC-5, Thomas Koenig wrote:
>> MitchAlsup <Mitch...@aol.com> schrieb:
>>> From the comp.arch layer of understanding::
>>> <
>>> What is it that ISAs can do to minimize the space of UB ?
>> We have discussed part of this before, but here is a bit
>> of an expansion (and some repetition).
>>
>> There are tools to find undefined behavior (or erroneous programs),
>> ranging from sanitizers (which add a low factor to execution time,
>> maybe two or so) to really heavy-handed tools like valgrind which
>> find a _lot_ of errors while making the code run abysmally slow.
>>
>> Think of ways that an ISA could be designed to speed up those tests.
>> Zero overhead is almost certainly unreachable, but even reducing
>> the speed overhead of checked code would help a lot.
>>
>> Going through the CERT coding standards, look for what can
>> be implemented either efficiently or at zero cost. An example:
>>
>> 5.1 INT30-C. Ensure that unsigned integer operations do not wrap.
> <
> unsigned integers are the only integral format that has well defined
> overflow characteristics == wrap. Why eliminate all wraps on the
> only format that actually wraps correctly ?

In the majority of cases of unsigned integer overflow, the answer is
wrong. It is well-defined, but wrong in the context where you are using
it. Adding an apple to a pile of 65535 apples and ending up with no
apples is only marginally less silly than adding an apple to a pile of
32767 apples and getting -32768 apples.

It is useful that C has a way of getting wrapping behaviour - as such
semantics are occasionally what you need. But defining semantics for
something that makes no logical sense in your code does not suddenly
give you the right answer - it just means you get the wrong answer
consistently.

Re: Paper about ISO C

<sm3geb$fhh$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Fri, 5 Nov 2021 15:51:54 +0100
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <sm3geb$fhh$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com>
<2021Nov2.094824@mips.complang.tuwien.ac.at>
<d71f0f03-ba1b-462c-bf7e-236003255918n@googlegroups.com>
<2021Nov2.173551@mips.complang.tuwien.ac.at> <sltddc$btq$1@dont-email.me>
<2021Nov3.092521@mips.complang.tuwien.ac.at> <sluebv$icv$1@dont-email.me>
<4620d9be-e530-4dbf-8672-ca45bdb2f248n@googlegroups.com>
<2021Nov4.182748@mips.complang.tuwien.ac.at> <sm1ioa$h41$1@dont-email.me>
<ecac9895-c898-40bf-8733-c90a3c498712n@googlegroups.com>
<2021Nov5.000057@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 5 Nov 2021 14:51:55 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="1024cedc26d9bb73e7d8ce5e94eb7aa4";
logging-data="15921"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19k/0AVT9gjwnJv4vW+QoiQhoecJjALyso="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:NtmJZDcuBmNjQ1xdNw/crcwt+Qs=
In-Reply-To: <2021Nov5.000057@mips.complang.tuwien.ac.at>
Content-Language: en-GB
 by: David Brown - Fri, 5 Nov 2021 14:51 UTC

On 05/11/2021 00:00, Anton Ertl wrote:
> MitchAlsup <MitchAlsup@aol.com> writes:
>>From the comp.arch layer of understanding::
>> <
>> What is it that ISAs can do to minimize the space of UB ?
>
> Not sure what you mean by that, but let me answer "What can in ISA do
> to make UB attractive (or less so)."
>
> The major reason why some people find undefined behaviour on integer
> overflow so attractive is the fact that the decision to go with
> I32LP64 requires sign-extending here and there with -fwrapv, e.g., with
> loops like
>
> for (int i=0; i<n; i++)
> r+=a[i];

I suppose it is possible that this is /a/ reason why some people like
signed integer overflow to be UB. But I would hardly call it "the
/major/ reason".

It is, however, one example of the kind of optimisation that compilers
can make when integer overflow is UB. And you can be quite confident
that in a case like this, the programmer had no intention of wanting "i"
to wrap.

Re: Paper about ISO C

<sm3hd8$msf$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Fri, 5 Nov 2021 16:08:24 +0100
Organization: A noiseless patient Spider
Lines: 79
Message-ID: <sm3hd8$msf$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com>
<2021Nov2.094824@mips.complang.tuwien.ac.at>
<d71f0f03-ba1b-462c-bf7e-236003255918n@googlegroups.com>
<2021Nov2.173551@mips.complang.tuwien.ac.at> <sltddc$btq$1@dont-email.me>
<2021Nov3.092521@mips.complang.tuwien.ac.at> <sluebv$icv$1@dont-email.me>
<4620d9be-e530-4dbf-8672-ca45bdb2f248n@googlegroups.com>
<2021Nov4.182748@mips.complang.tuwien.ac.at> <sm1ioa$h41$1@dont-email.me>
<ecac9895-c898-40bf-8733-c90a3c498712n@googlegroups.com>
<2021Nov5.000057@mips.complang.tuwien.ac.at>
<26c1bc56-4e5c-4da5-a16f-3ee778478dccn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 5 Nov 2021 15:08:24 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="1024cedc26d9bb73e7d8ce5e94eb7aa4";
logging-data="23439"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/FkigYl16dK9VnZFVZ46b5hk37CqfjfrM="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:OgutZz0ef+fMvcYcaI11M0kU7XI=
In-Reply-To: <26c1bc56-4e5c-4da5-a16f-3ee778478dccn@googlegroups.com>
Content-Language: en-GB
 by: David Brown - Fri, 5 Nov 2021 15:08 UTC

On 05/11/2021 00:56, MitchAlsup wrote:
> On Thursday, November 4, 2021 at 6:21:39 PM UTC-5, Anton Ertl wrote:
>> MitchAlsup <Mitch...@aol.com> writes:
>> >From the comp.arch layer of understanding::
>>> <
>>> What is it that ISAs can do to minimize the space of UB ?
>> Not sure what you mean by that, but let me answer "What can in ISA do
>> to make UB attractive (or less so)."
>>
>> The major reason why some people find undefined behaviour on integer
>> overflow so attractive is the fact that the decision to go with
>> I32LP64 requires sign-extending here and there with -fwrapv, e.g., with
>> loops like
>>
>> for (int i=0; i<n; i++)
>> r+=a[i];
>>
>> The address of a is 64 bits, but i is a signed 32-bit value, and needs
>> to be sign-extended with -fwrapv when forming a+i on every iteration
>> of the loop.
> <
> For a new ISA, why would anyone go with I32LP64 why not ILP64 ?

With 64-bit integers, the great majority of the issues with integer
overflow just disappear.

But it would surprise some people in their coding, and might cause
trouble for those that made assumptions about the size of "int". You
would also have to add an extended integer type in order to get int16_t
and int32_t, which are useful types to have.

Despite that, I think it would be a good idea.

> <
> But why can 'n' not be checked for being "too big" before running the loop
> and avoid all of the a+i checking "in the loop". Here, the check seems easy
> enough (n>=0):: but it seems the real problem is that there is nothing close
> to the loop supplying the bounds for a[] !!?!
> <

If the compiler knows about the size of the array, or the size of n,
then it could avoid any additional work regardless of -fwrapv semantics.
And yes, I think if these were unknown, then the check could be hoisted
to the start of the loop rather than doing any kind of sign-extension in
the loop.

>> If the instruction generated for i++ sign-extends (like
>> Alpha's addl, but then Alpha have a similar problem if i was defined
>> as unsigned; so we would need both sign-extending and zero-extending
>> variants), you don't need to sign-extend with an extra intruction.
> <
> In I32LP64 codes, Brian's My 66000 C compiler spits out copious
> quantities of EXT Rx,Rx,<31:0> // extract the lower 32 bits and sign
> extend.
> <
>> Alternatively, if the address computation supports sign-extended
>> 32-bit arguments (IIRC Aarch64 has such addressing modes), this is
>> another way of avoiding the extra instruction. Finally,
>> sign-extension instructions could be made zero-cost in implementations
>> (like zero-extending is in some implementations), this might also
>> reduce the attraction (but I guess that the effect would be smaller,
>> because an instruction always has a psychological cost.
>> - anton
>> --
>> 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
>> Mitch Alsup, <c17fcd89-f024-40e7...@googlegroups.com>
> <
> But I was wondering more about doing things like::
> <
> int a >> int b; // where b is allowed to be negative
> int a << int b; // where b is allowed to be negative
> <
> And when a shift count is negative, the shift is performed in the "other" direction.
>

I am not sure these occur very often in code. More common, I would
expect, are cases where "a" is negative, or where "b" is greater than or
equal to the width of the type. If the ISA has a particular fixed way
to handle these, then those semantics could be added to the compiler.

Re: Paper about ISO C

<sm3hp1$pnh$1@dont-email.me>

  copy mid

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

  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: Paper about ISO C
Date: Fri, 5 Nov 2021 16:14:40 +0100
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <sm3hp1$pnh$1@dont-email.me>
References: <2021Nov4.182748@mips.complang.tuwien.ac.at>
<memo.20211104214335.12308C@jgd.cix.co.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 5 Nov 2021 15:14:41 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="1024cedc26d9bb73e7d8ce5e94eb7aa4";
logging-data="26353"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18cdFbPQdUDx5ixVOMNS3dWM2bK/vPxgAM="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:UTYJxU+4wD3htgCj6daL3bpILAU=
In-Reply-To: <memo.20211104214335.12308C@jgd.cix.co.uk>
Content-Language: en-GB
 by: David Brown - Fri, 5 Nov 2021 15:14 UTC

On 04/11/2021 22:42, John Dallman wrote:
> In article <2021Nov4.182748@mips.complang.tuwien.ac.at>,
> anton@mips.complang.tuwien.ac.at (Anton Ertl) wrote:
>
>> The issue is: If a program has been tested and works on one or
>> several versions of a C compiler, and it does not work on a new
>> version of the same compiler on the same architecture(s), is
>> it a regression in the compiler (my position), or has the program
>> been broken all the time, and the earlier compiler releases were
>> just not advanced enough to expose this brokenness earlier.
>
> The question does not have a general answer IME. I've encountered this
> situation many times. The results have included:
>
> "Yes, the compiler really has a regression." Sometimes that is easy to
> decide, sometimes you have to dig a fair bit to be sure.
>
> "No, I can't blame the compiler for misunderstanding this code." Because
> it's complex or twisted in some strange way that previous compilers
> didn't notice.
>
> And occasionally, "What the hell was the developer thinking? Why did any
> compiler ever do anything sensible with this?"
>

I've been there. I once had to fix a program I inherited where the
programmer tended to declare external functions randomly throughout the
C files that used them, rather than in a nicely structure header. The
result was that the function definitions might be changed later to have
different numbers or types of parameters, while the declarations and
uses kept the old parameter sets. The program "worked", for the most
part, except for a few odd bugs. But it worked due to coincidences of
what happened to be in particular registers before and after these
broken function calls. No compiler could be expected to replicate such
behaviour when changing to a new version!

Re: Paper about ISO C

<sm3o5a$mhk$1@newsreader4.netcologne.de>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd6-a34-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Fri, 5 Nov 2021 17:03:38 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <sm3o5a$mhk$1@newsreader4.netcologne.de>
References: <87fstdumxd.fsf@hotmail.com>
<2021Oct27.231122@mips.complang.tuwien.ac.at> <slgs05$7rf$1@dont-email.me>
<2021Nov1.182821@mips.complang.tuwien.ac.at>
<slpo0e$34b$1@newsreader4.netcologne.de>
<2021Nov2.094824@mips.complang.tuwien.ac.at>
<d71f0f03-ba1b-462c-bf7e-236003255918n@googlegroups.com>
<2021Nov2.173551@mips.complang.tuwien.ac.at> <sltddc$btq$1@dont-email.me>
<2021Nov3.092521@mips.complang.tuwien.ac.at> <sluebv$icv$1@dont-email.me>
<4620d9be-e530-4dbf-8672-ca45bdb2f248n@googlegroups.com>
<2021Nov4.182748@mips.complang.tuwien.ac.at> <sm1ioa$h41$1@dont-email.me>
<ecac9895-c898-40bf-8733-c90a3c498712n@googlegroups.com>
<sm1mgr$dt6$1@newsreader4.netcologne.de>
<826ad4e3-8b1f-4fdd-819d-e46647e30019n@googlegroups.com>
Injection-Date: Fri, 5 Nov 2021 17:03:38 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd6-a34-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd6:a34:0:7285:c2ff:fe6c:992d";
logging-data="23092"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Fri, 5 Nov 2021 17:03 UTC

MitchAlsup <MitchAlsup@aol.com> schrieb:
> On Thursday, November 4, 2021 at 5:23:25 PM UTC-5, Thomas Koenig wrote:
>> MitchAlsup <Mitch...@aol.com> schrieb:
>> > From the comp.arch layer of understanding::
>> ><
>> > What is it that ISAs can do to minimize the space of UB ?
>> We have discussed part of this before, but here is a bit
>> of an expansion (and some repetition).
>>
>> There are tools to find undefined behavior (or erroneous programs),
>> ranging from sanitizers (which add a low factor to execution time,
>> maybe two or so) to really heavy-handed tools like valgrind which
>> find a _lot_ of errors while making the code run abysmally slow.
>>
>> Think of ways that an ISA could be designed to speed up those tests.
>> Zero overhead is almost certainly unreachable, but even reducing
>> the speed overhead of checked code would help a lot.
>>
>> Going through the CERT coding standards, look for what can
>> be implemented either efficiently or at zero cost. An example:
>>
>> 5.1 INT30-C. Ensure that unsigned integer operations do not wrap.
><
> unsigned integers are the only integral format that has well defined
> overflow characteristics == wrap. Why eliminate all wraps on the
> only format that actually wraps correctly ?

If it is wrapping "correctly" or not depends on what is done with
it, and what the programmer intended.

The CERT C coding standards cites four vulnerabilities because
due to this kind of thing, among them CVE-2009-1385 (a Linux
kernel vulnerability), a vmsplice exploit in Linux, an integer
wrap vulnerability in LZO and an iOS 7.1 vulnerability due to
a multiplication resuling in a too-small memory amount.

The full text (which is longish, but can be browsed for a general
overview rather quickly) can be found at

https://resources.sei.cmu.edu/downloads/secure-coding/assets/sei-cert-c-coding-standard-2016-v01.pdf

Pages:123456789101112131415161718192021222324252627282930313233
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor