Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

C:\> WIN Bad command or filename C:\> LOSE Loading Microsoft Windows ...


devel / comp.arch / 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

<sk9j4v$lhk$1@newsreader4.netcologne.de>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: rocksolid2!news.neodome.net!feeder1.feed.usenet.farm!feed.usenet.farm!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-f01f-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, 14 Oct 2021 15:42:23 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <sk9j4v$lhk$1@newsreader4.netcologne.de>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk8jd2$v86$1@newsreader4.netcologne.de>
<9157851d-afcf-454a-908a-2e159fb1e3f2n@googlegroups.com>
Injection-Date: Thu, 14 Oct 2021 15:42:23 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-f01f-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:f01f:0:7285:c2ff:fe6c:992d";
logging-data="22068"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Thu, 14 Oct 2021 15:42 UTC

Victor Yodaiken <victor.yodaiken@gmail.com> schrieb:

A general point: On Usenet, it is considered good form to
limit line lengths to 72. Would you mind following that
convention? I keep having to re-break your lines in
quotaions. Thanks!

> On Thursday, October 14, 2021 at 1:40:35 AM UTC-5, Thomas Koenig wrote:
>> Victor Yodaiken schrieb:
>> > The paper really focuses on the example of alias optimizations
>> > and Dennis Ritchie's strong - and prescient warnings.
>> Dennis Ritchie was warning about a specific feature which did
>> not make it into the language.
>>
>
> His warning - including his discussion of Fortran which you
> might want to read, is generally applicable.

Dennis Ritchie in 1988 could hardly have known Fortran 90.

>> One of the design faults of C is the overuse of pointers,
>> specifically for array access (including pointer arithmetic),
>
>
> If you don't like C and don't appreciate its design basis, then your opinion of
> what optimizations are reasonable may not be as insightful as you believe.

Huh?

I do like the language (I use it quite often), but I am
not blind to its faults.

> C pointers are extremely useful for some applications. But
> certainly other approaches have advantages in other applications.

>
>>
>> Now, consider:
>>
>> float *fp;
>> int *fp;
>> float a;
>>
>> /* ... */
>>
>> *fp = something;
>> *ip = something_else;
>> printf ("%f", *fp);
>>
>> Assume that the value of *fp is held in a register. Should the
>> store to *ip make a reload of fp necessary before the printf?
>
> This depends on whether the pointers point to the same object.

Um... and how does the compiler determine that?

This is exactly the point - in the absence of other information,
(for example in pointers passed to a function), the compiler _must_
reload *fp if you have it your way. You quite vehemently argue
for this.

According to the C standard (and to my preference) it need not do
so, because of the difference in type.

>
>
>> > And part of the reason is because sound alias analysis is much
>> > *harder* for compilers than alias assumptions.
>> Which is why I like the Fortran model much better. In Fortran,
>>
>
> I am happy for you and I agree that Fortran is well suited to certain types
> of applications.
>
>> - if you have overlapping dummy arguments, you cannot store
>> a value through one and access it through another one
>> (which is rarely checked, unfortunately)
>
> Indeed. And why is that?

In the case of gfortran, because nobody to date has stepped
up to write a patch. There is also a run-time overhead.

> If I had known about Fortran's issues with alias analysis, I
> might have even included in a 6 page paper a reference to Fortran
> alias analysis -something like this:

> " Fortran has similar problems with similar assumptions:
> "anything may happen: the program may appear to run normally,
> or produce incorrect answers, or behave unpredictably." [24]."

In Fortran, the wording is clearer than C's weasel-word "undefined
behavior". Code which does so is in violation of a "shall"
directive, so the program is erronous. This is not a violation
of a constraint (which are clearly labeled and numbered) so a
compiler is not required to diagnose it.

Case closed.

>
>> > Since you bring it up, for me the way C originally handled
>> > integer overflow was sloppy and sometimes dangerous - it was an
>> > engineering tradeoff made to make fast code and simple compilation.
>> > BUT the ISO-C approach is mathematically incoherent and even more
>> > dangerous - because semantics is unpredictable.
>> Signed integer overflow is an error, period (the same in
>> Fortran as in C).
>> > Ironically, as C compilers muddied int arithmetic, processors
>> > became much better about native signed arithmetic. Mod 2^k 2s
>> > complement, which is native on the vast majority of modern
>> > processors is mathematically coherent even if it is hard to
>> > work with.
>> Very hard, and a source of errors...
>
> Programming is hard. Some languages have runtime to catch
> those errrors,

Run-time checks to catch thinking errors in mod 2^n arithmetic?
I am amazed, please tell me what these are.

> and even in some C compilers we have an option for ftrapv. But
> there are tradeoffs. This is why Fortran uses floating point
> arithmetic even though it is a notorious source of errors.

C also uses floating point, in case you had not noticed - the types
are called "float" and "double".

>> > But what we have in ISO C makes arithmetic depend on vagaries
>> > of the optimizer and produces paradoxes.
>> Ah, no. It means that an erroneous program gets random results,
>
> With modular arithmetic, or even saturating as you have on some
> processors, you do not get random results. You may not get the
> results you expect if you think 4 byte or even 8 or 16 byte "ints"
> can represent all of Z.

You are confusing the C language with whatever happens on a
particular system. Might I point out section 5.1.2.3 of n2346.pdf:

# The semantic descriptions in this document describe the behavior of
# an abstract machine in which issues of optimization are irrelevant.

The C standard is the specification for that abstract machine.
As long as you stick to that, you're reasonably safe (and you can
holler at compiler writers if you find bugs). If you insist on
peculiarities of a particular implementation... well, you violated
the contract, it's your fault.

> If you adopt the axiom that overflow is programming error,
> than you will conclude it is a programming error, but that's not
> super illuminating.

It is a programming error iff the specification says it is.
If you have a language whose spec says that 32767 + 1 = -32868,
that is another matter. I'm not aware of such a language, but
there may well be one.

>> which is not surprising. Would you also like to prosrcribe results
>> for array overruns?
>
> Indeed I would.

OK, I can live with that. It would incur significant run-time
overhead, but one goal of compiler writes is to reduce that
run-time overhead.

For example, I would like the run-time cheks for

subroutine foo(a,n, i)
integer, dimension(n) :: a
if (i > n) stop "Nope!"
do j=1,i
a(i) = 1.0
end do
end subroutine foo

to be removed by optimization.

>
>>Ada does so, and both it and Fortran are
>> better languages if you want to have a lower error rate than for C.
>>

> What's fascinating for me is how many people who consider C
> to be a botched language from the start

I'm not one of them. C has its strenghts and its weaknesses,
as has every other programming languages.

>are so interested in insisting on their ideas for C semantics.

It's what is written in the standard, not somebody's idea.

> C is useful for some applications, less for others. We have
> different languages for a reason. Fortran is not inferior to Haskell
> because it does not offer bignumbers as default. One would not want
> to write finite element analysis programs in Haskell. Similarly,
> I would not want to attempt operating systems or cryptography
> coding in Fortran.

Cryptography would be somewhat hampered by Fortran not having
unsigned numbers.

Re: GCC on M1 [Was: Re: Paper about ISO C]

<sk9j9l$lhk$2@newsreader4.netcologne.de>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: rocksolid2!news.neodome.net!news.uzoreto.com!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-f01f-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch
Subject: Re: GCC on M1 [Was: Re: Paper about ISO C]
Date: Thu, 14 Oct 2021 15:44:53 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <sk9j9l$lhk$2@newsreader4.netcologne.de>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<sjugcv$jio$1@dont-email.me>
<cb6bbb41-398f-4e2a-9a19-08bc4582b291n@googlegroups.com>
<sk437c$672$1@dont-email.me>
<0d336dad-0078-4783-9d13-635d1d061704n@googlegroups.com>
<f94c96c4-af61-4a60-b182-db213690c340n@googlegroups.com>
<C7q9J.45174$tA2.43354@fx02.iad> <sk5cp7$26i$1@dont-email.me>
<apr9J.205378$Kv2.138883@fx47.iad> <sk5ngm$og9$1@dont-email.me>
<_ox9J.87698$ol1.33401@fx42.iad> <sk6jvj$k6t$3@newsreader4.netcologne.de>
<16adebe6488f696a$1$3213316$8d54264@news.newsdemon.com>
Injection-Date: Thu, 14 Oct 2021 15:44:53 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-f01f-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:f01f:0:7285:c2ff:fe6c:992d";
logging-data="22068"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Thu, 14 Oct 2021 15:44 UTC

nemo <invalid@invalid.invalid> schrieb:
> On 2021-10-13 08:38, Thomas Koenig wrote:
> [...]
>>
>> AFAIK, there will be M1 support in gcc 12. Interestingly enough,
>> it was the lack of a Fortran compiler which mostly drove demand
>> for this port.
>
> Well, getting there... Configure accepts it but the next level down
> spits out:
> *** Configuration aarch64-apple-darwin20.4.0 not supported

Not in there yet.

See https://gcc.gnu.org/pipermail/gcc/2021-September/237340.html
for the announcement.

Re: Paper about ISO C

<sk9l00$e17$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: sfu...@alumni.cmu.edu.invalid (Stephen Fuld)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Thu, 14 Oct 2021 09:13:50 -0700
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <sk9l00$e17$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk8jd2$v86$1@newsreader4.netcologne.de> <Q9U9J.190243$o45.179981@fx46.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 14 Oct 2021 16:13:52 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="7a999136a081e2afa6618326694424de";
logging-data="14375"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX190K2YEts6CzIURGYbGCoLnE1vS+Ycfusk="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.2.0
Cancel-Lock: sha1:inQ66ZY1oRnT6izEYpBgea+xcUY=
In-Reply-To: <Q9U9J.190243$o45.179981@fx46.iad>
Content-Language: en-US
 by: Stephen Fuld - Thu, 14 Oct 2021 16:13 UTC

On 10/14/2021 4:05 AM, Branimir Maksimovic wrote:

snip

> Fortran is pre structured era, spagetti code. Good for
> arrays, not mutch for anything else :P
> Good luck with network code or parsing with FORTRAN :P

Sort of. FORTRAN was defined pre structured era, but it added
structuring features decades ago.

As for parsing, in the late 1970s, I used AMDASM, an assembler for 2901
bit sliced CPUs that was written in FORTRAN. It worked fine.

--
- Stephen Fuld
(e-mail address disguised to prevent spam)

Re: Paper about ISO C

<sk9n30$nm7$3@newsreader4.netcologne.de>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: rocksolid2!news.neodome.net!news.uzoreto.com!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-f01f-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, 14 Oct 2021 16:49:36 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <sk9n30$nm7$3@newsreader4.netcologne.de>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk9ej9$fj9$1@dont-email.me>
<b230d3fe-324f-491e-9e70-5398f1b68b3cn@googlegroups.com>
Injection-Date: Thu, 14 Oct 2021 16:49:36 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-f01f-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:f01f:0:7285:c2ff:fe6c:992d";
logging-data="24263"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Thu, 14 Oct 2021 16:49 UTC

Victor Yodaiken <victor.yodaiken@gmail.com> schrieb:
> On Thursday, October 14, 2021 at 9:24:43 AM UTC-5, David Brown wrote:
>
>> The standard has to provide the lowest common denominator - the most
>> vague version of the language, with the most undefined behaviours and
>> implementation-defined behaviours. It is then up to implementations to
>> tighten these details as appropriate, or offer options for additional
>> semantics.
>>
>
> I disagree. Overuse of UB degrades the semantics of the language
> and reduces its utility. The overhead in dealing with unpredictable
> unsound optimizations is a serious drag on the utility of C.

Let's called "undefined behavior" what it is - programming errors,
and see how much your sentence makes sense then.

Re: Paper about ISO C

<e325b8a8-d8c9-41fa-ad49-10709a12da7an@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ad4:48d4:: with SMTP id v20mr6380080qvx.42.1634230490872;
Thu, 14 Oct 2021 09:54:50 -0700 (PDT)
X-Received: by 2002:a9d:200e:: with SMTP id n14mr3415791ota.85.1634230490516;
Thu, 14 Oct 2021 09:54:50 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.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, 14 Oct 2021 09:54:50 -0700 (PDT)
In-Reply-To: <sk9j4v$lhk$1@newsreader4.netcologne.de>
Injection-Info: google-groups.googlegroups.com; posting-host=24.173.181.154; posting-account=jn4_9AoAAADlg7v8KtkkjWBduIrvz8VB
NNTP-Posting-Host: 24.173.181.154
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com> <3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me> <1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk8jd2$v86$1@newsreader4.netcologne.de> <9157851d-afcf-454a-908a-2e159fb1e3f2n@googlegroups.com>
<sk9j4v$lhk$1@newsreader4.netcologne.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e325b8a8-d8c9-41fa-ad49-10709a12da7an@googlegroups.com>
Subject: Re: Paper about ISO C
From: victor.y...@gmail.com (Victor Yodaiken)
Injection-Date: Thu, 14 Oct 2021 16:54:50 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 272
 by: Victor Yodaiken - Thu, 14 Oct 2021 16:54 UTC

On Thu, Oct 14, 2021 at 10:42 AM Thomas Koenig wrote:
>>Victor Yodaiken schrieb:

>A general point: On Usenet, it is considered good form to
>limit line lengths to 72. Would you mind following that
>convention? I keep having to re-break your lines in
>quotaions. Thanks!

i will try. I may have inconsistent quoting in this reply, so please forgive me.

>> On Thursday, October 14, 2021 at 1:40:35 AM UTC-5, Thomas Koenig wrote:
>>> Victor Yodaiken schrieb:
>>> > The paper really focuses on the example of alias optimizations
>>> > and Dennis Ritchie's strong - and prescient warnings.
>>> Dennis Ritchie was warning about a specific feature which did
>>> not make it into the language.
>>>
>>
>>> His warning - including his discussion of Fortran which you
>> might want to read, is generally applicable.

>Dennis Ritchie in 1988 could hardly have known Fortran 90.

in 1988 there was significant experience with Fortran optimization, particularly, with
alias analysis. Not all that much changed by 1990.

>> One of the design faults of C is the overuse of pointers,
>> specifically for array access (including pointer arithmetic),
>
>
> If you don't like C and don't appreciate its design basis, then your opinion of
> what optimizations are reasonable may not be as insightful as you believe..

>Huh?

>I do like the language (I use it quite often), but I am
>not blind to its faults.

Overuse of pointers is a key part of what makes C useful.


>> C pointers are extremely useful for some applications. But
>> certainly other approaches have advantages in other applications.

>>
>>>
>>> Now, consider:
>>>
>>> float *fp;
>>> int *fp;
>>> float a;
>>>
>>> /* ... */
>>>
>>> *fp = something;
>>> *ip = something_else;
>>> printf ("%f", *fp);
>>>
>>> Assume that the value of *fp is held in a register. Should the
>>> store to *ip make a reload of fp necessary before the printf?
>>
>> This depends on whether the pointers point to the same object.
>
>Um... and how does the compiler determine that?
>
>This is exactly the point - in the absence of other information,
>(for example in pointers passed to a function), the compiler _must_
>reload *fp if you have it your way. You quite vehemently argue
>for this.

I am against unsound transformations. For example, transforming a
double float radix sort into a no-op would not be sound.
>According to the C standard (and to my preference) it need not do
>so, because of the difference in type.

I think that is a significant reduction in C expressive range and not at all worth
the minimal optimization gains.


>>
>>
>>> > And part of the reason is because sound alias analysis is much
>>> > *harder* for compilers than alias assumptions.
>>> Which is why I like the Fortran model much better. In Fortran,
>>>
>>
>> I am happy for you and I agree that Fortran is well suited to certain types
>> of applications.
>>
>>> - if you have overlapping dummy arguments, you cannot store
>>> a value through one and access it through another one
>>> (which is rarely checked, unfortunately)
>>
>> Indeed. And why is that?
>
>In the case of gfortran, because nobody to date has stepped
>up to write a patch. There is also a run-time overhead.

Yes.
>> If I had known about Fortran's issues with alias analysis, I
>> might have even included in a 6 page paper a reference to Fortran
>> alias analysis -something like this:
>
>> " Fortran has similar problems with similar assumptions:
>> "anything may happen: the program may appear to run normally,
>> or produce incorrect answers, or behave unpredictably." [24]."
>
>In Fortran, the wording is clearer than C's weasel-word "undefined
>behavior".

Absolutely agree that "undefined behavior" is an awful concept.
I think it is used to evade burden on the compilers for error checking and
to evade plainly stating proposed limitations to C expressiveness.
>Code which does so is in violation of a "shall"
>directive, so the program is erronous. This is not a violation
>of a constraint (which are clearly labeled and numbered) so a
>compiler is not required to diagnose it.
>
>Case closed.

>>
>>> > Since you bring it up, for me the way C originally handled
>>> > integer overflow was sloppy and sometimes dangerous - it was an
>>> > engineering tradeoff made to make fast code and simple compilation.
>>> > BUT the ISO-C approach is mathematically incoherent and even more
>>> > dangerous - because semantics is unpredictable.
>>> Signed integer overflow is an error, period (the same in
>>> Fortran as in C).
>>> > Ironically, as C compilers muddied int arithmetic, processors
>>> > became much better about native signed arithmetic. Mod 2^k 2s
>>> > complement, which is native on the vast majority of modern
>>> > processors is mathematically coherent even if it is hard to
>>> > work with.
>>> Very hard, and a source of errors...
>>
>> Programming is hard. Some languages have runtime to catch
>> those errrors,
>
>Run-time checks to catch thinking errors in mod 2^n arithmetic?
>I am amazed, please tell me what these are.

You can, if you want, select ftrapv on both gcc and clang. This will catch overflows.
>> and even in some C compilers we have an option for ftrapv. But
>> there are tradeoffs. This is why Fortran uses floating point
>> arithmetic even though it is a notorious source of errors.
>
>C also uses floating point, in case you had not noticed - the types
>are called "float" and "double".

It does for the same reason.
>>> > But what we have in ISO C makes arithmetic depend on vagaries
>>> > of the optimizer and produces paradoxes.
>>> Ah, no. It means that an erroneous program gets random results,
>>
>> With modular arithmetic, or even saturating as you have on some
>> processors, you do not get random results. You may not get the
>> results you expect if you think 4 byte or even 8 or 16 byte "ints"
>> can represent all of Z.
>
>You are confusing the C language with whatever happens on a
>particular system. Might I point out section 5.1.2.3 of n2346.pdf:

You are confusing your interpretation of C standard for laws of physics. I propose
different semantics.
BTW: C overflow semantics are not described in the C standard at all. The standard
leaves it up to the implementation.
># The semantic descriptions in this document describe the behavior of
># an abstract machine in which issues of optimization are irrelevant.
>
>The C standard is the specification for that abstract machine.
>As long as you stick to that, you're reasonably safe (and you can
>holler at compiler writers if you find bugs). If you insist on
>peculiarities of a particular implementation... well, you violated
>the contract, it's your fault.
>

And overflow is specifically stated to be undefined. So an implementation
that, for example, adopts target architecture arithmetic semantics is following the standard
as much or more than one that interprets "undefined" to mean "impossible".
In fact, the interpretation of undefined to mean "not possible" is controversial and
not particularly well founded in the text or history of the standard. It is actually
a byproduct of how certain intermediate languages work. It is convenient in gcc/clang
to treat UB as impossible, but that's a bizarre way to come up with semantics.
>> If you adopt the axiom that overflow is programming error,
>> than you will conclude it is a programming error, but that's not
>> super illuminating.
>
>It is a programming error iff the specification says it is.

Which it does not.
>If you have a language whose spec says that 32767 + 1 = -32868,
>that is another matter. I'm not aware of such a language, but
>there may well be one.

C standard says

"the sign bit has the value −(2 M ) (two’s complement);"

with choice of integer representation being implementation defined.
So in C where sizeof(short) = 2 and, as it assumes but doesn't make
clear anywhere, bytes are 8 bits, we know there are only 2^{16} possible
values and there is no representation of 32768 in 2s complement in
16 bits. then, if we care about mathematical consistency,
32767+1 = -32868


Click here to read the complete article
Re: Paper about ISO C

<6f3a3f2c-c066-46fc-bd15-7e31ac1846f3n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a37:c83:: with SMTP id 125mr6021185qkm.453.1634232623980;
Thu, 14 Oct 2021 10:30:23 -0700 (PDT)
X-Received: by 2002:a05:6830:82f:: with SMTP id t15mr3839352ots.142.1634232623693;
Thu, 14 Oct 2021 10:30:23 -0700 (PDT)
Path: rocksolid2!news.neodome.net!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, 14 Oct 2021 10:30:23 -0700 (PDT)
In-Reply-To: <Q9U9J.190243$o45.179981@fx46.iad>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:5574:8c85:ed4a:262f;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:5574:8c85:ed4a:262f
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com> <3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me> <1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk8jd2$v86$1@newsreader4.netcologne.de> <Q9U9J.190243$o45.179981@fx46.iad>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6f3a3f2c-c066-46fc-bd15-7e31ac1846f3n@googlegroups.com>
Subject: Re: Paper about ISO C
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Thu, 14 Oct 2021 17:30:23 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 101
 by: MitchAlsup - Thu, 14 Oct 2021 17:30 UTC

On Thursday, October 14, 2021 at 6:05:22 AM UTC-5, Branimir Maksimovic wrote:
> On 2021-10-14, Thomas Koenig <tko...@netcologne.de> wrote:
> > Victor Yodaiken <victor....@gmail.com> schrieb:
> >
> >> The paper really focuses on the example of alias optimizations
> >> and Dennis Ritchie's strong - and prescient warnings.
> >
> > Dennis Ritchie was warning about a specific feature which did
> > not make it into the language.
> >
> > [...]
> >
> >> Again, I don't have to believe that Ritchie was always right
> >> about everything to consider him one of the most brilliant CS
> >> researchers/programmers and to find his arguments on this issue
> >> strong. And I don't even have to oppose all alias analysis -
> >> in fact, I think, the type based approach taken by ISO reduces
> >> the expressive range of the language, creates complexity and
> >> murky semantics, AND leaves a lot of alias based optimization on
> >> the table.
> >
> > One of the design faults of C is the overuse of pointers,
> > specifically for array access (including pointer arithmetic),
> > dynamic memory allocation and for argument passing. While a
> > good design decision for the 1970s with limited resources for a
> > compiler, the very first high-level programming language, FORTRAN,
> > had already handled parts of this better.
> >
> > Now, consider:
> >
> > float *fp;
> > int *fp;
> > float a;
> >
> > /* ... */
> >
> > *fp = something;
> > *ip = something_else;
> > printf ("%f", *fp);
> >
> > Assume that the value of *fp is held in a register. Should the
> > store to *ip make a reload of fp necessary before the printf?
> >
> >> And part of the reason is because sound alias analysis is much
> >> *harder* for compilers than alias assumptions.
> >
> > Which is why I like the Fortran model much better. In Fortran,
> >
> > - if you have overlapping dummy arguments, you cannot store
> > a value through one and access it through another one
> > (which is rarely checked, unfortunately)
> >
> > - variables which can be a target of a pointer must be
> > marked TARGET
> >
> > - you have allocatable variables (which are automatically
> > deallocated when they go out of scope), which are not
> > TARGETs and which cannot alias anything else
> >
> > - Pointers can also point to multi-dimensional arrays
> >
> > (and teaching the somewhat C-centric gcc about optimizations
> > possible according to the Fortran language definition is an
> > ongoing process).
> >
> >> Since you bring it up, for me the way C originally handled
> >> integer overflow was sloppy and sometimes dangerous - it was an
> >> engineering tradeoff made to make fast code and simple compilation.
> >> BUT the ISO-C approach is mathematically incoherent and even more
> >> dangerous - because semantics is unpredictable.
> >
> > Signed integer overflow is an error, period (the same in
> > Fortran as in C).
> >
> >> Ironically, as C compilers muddied int arithmetic, processors
> >> became much better about native signed arithmetic. Mod 2^k 2s
> >> complement, which is native on the vast majority of modern
> >> processors is mathematically coherent even if it is hard to
> >> work with.
> >
> > Very hard, and a source of errors...
> >
> >> But what we have in ISO C makes arithmetic depend on vagaries
> >> of the optimizer and produces paradoxes.
> >
> > Ah, no. It means that an erroneous program gets random results,
> > which is not surprising. Would you also like to prosrcribe results
> > for array overruns? Ada does so, and both it and Fortran are
> > better languages if you want to have a lower error rate than for C.
> >
> > You will not have much luck changing C.
> Fortran is pre structured era, spagetti code. Good for
> arrays, not mutch for anything else :P
> Good luck with network code or parsing with FORTRAN :P
<
I lead a team that built a FORTRAN runtime library using nothing other
than FORTRAN.
> --
>
> 7-77-777
> Evil Sinner!
> with software, you repeat same experiment, expecting different results...

Re: Paper about ISO C

<sk9qfi$pa3$2@newsreader4.netcologne.de>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: rocksolid2!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-f01f-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, 14 Oct 2021 17:47:30 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <sk9qfi$pa3$2@newsreader4.netcologne.de>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk8jd2$v86$1@newsreader4.netcologne.de>
<9157851d-afcf-454a-908a-2e159fb1e3f2n@googlegroups.com>
<sk9j4v$lhk$1@newsreader4.netcologne.de>
<e325b8a8-d8c9-41fa-ad49-10709a12da7an@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 14 Oct 2021 17:47:30 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-f01f-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:f01f:0:7285:c2ff:fe6c:992d";
logging-data="25923"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Thu, 14 Oct 2021 17:47 UTC

Victor Yodaiken <victor.yodaiken@gmail.com> schrieb:
>
> On Thu, Oct 14, 2021 at 10:42 AM Thomas Koenig wrote:
>>>Victor Yodaiken schrieb:
>
>>A general point: On Usenet, it is considered good form to
>>limit line lengths to 72. Would you mind following that
>>convention? I keep having to re-break your lines in
>>quotaions. Thanks!
>
>
> i will try. I may have inconsistent quoting in this reply, so please forgive me.
>
>>> On Thursday, October 14, 2021 at 1:40:35 AM UTC-5, Thomas Koenig wrote:
>>>> Victor Yodaiken schrieb:
>>>> > The paper really focuses on the example of alias optimizations
>>>> > and Dennis Ritchie's strong - and prescient warnings.
>>>> Dennis Ritchie was warning about a specific feature which did
>>>> not make it into the language.
>>>>
>>>
>>>> His warning - including his discussion of Fortran which you
>>> might want to read, is generally applicable.
>
>>Dennis Ritchie in 1988 could hardly have known Fortran 90.
>
>
> in 1988 there was significant experience with Fortran optimization, particularly, with
> alias analysis. Not all that much changed by 1990.

[ ] You know the first thing about Fortran and Fortran standards.

>
>>> One of the design faults of C is the overuse of pointers,
>>> specifically for array access (including pointer arithmetic),
>>
>>
>> If you don't like C and don't appreciate its design basis, then your opinion of
>> what optimizations are reasonable may not be as insightful as you believe.
>
>>Huh?
>
>>I do like the language (I use it quite often), but I am
>>not blind to its faults.

> Overuse of pointers is a key part of what makes C useful.

"Overuse" implies "too much", so I doubt that this
is what you meant.

>>> C pointers are extremely useful for some applications. But
>>> certainly other approaches have advantages in other applications.
>
>>>
>>>>
>>>> Now, consider:
>>>>
>>>> float *fp;
>>>> int *fp;
>>>> float a;
>>>>
>>>> /* ... */
>>>>
>>>> *fp = something;
>>>> *ip = something_else;
>>>> printf ("%f", *fp);
>>>>
>>>> Assume that the value of *fp is held in a register. Should the
>>>> store to *ip make a reload of fp necessary before the printf?
>>>
>>> This depends on whether the pointers point to the same object.
>>
>>Um... and how does the compiler determine that?
>>
>>This is exactly the point - in the absence of other information,
>>(for example in pointers passed to a function), the compiler _must_
>>reload *fp if you have it your way. You quite vehemently argue
>>for this.

> I am against unsound transformations. For example, transforming a
> double float radix sort into a no-op would not be sound.

I cannot understand how this sentence applies to what I wrote,
so I take it you concur with what I wrote.

>>According to the C standard (and to my preference) it need not do
>>so, because of the difference in type.
>
>
> I think that is a significant reduction in C expressive range
> and not at all worth the minimal optimization gains.

[Again, would you mind following Usenet conventions with line
breaking? Thanks.]

What you want will impede a lot of vectorization on current
architectures, then. [Yes, Mitch's VVM is better that way :-]

>>>> > And part of the reason is because sound alias analysis is much
>>>> > *harder* for compilers than alias assumptions.
>>>> Which is why I like the Fortran model much better. In Fortran,
>>>>
>>>
>>> I am happy for you and I agree that Fortran is well suited to certain types
>>> of applications.
>>>
>>>> - if you have overlapping dummy arguments, you cannot store
>>>> a value through one and access it through another one
>>>> (which is rarely checked, unfortunately)
>>>
>>> Indeed. And why is that?
>>
>>In the case of gfortran, because nobody to date has stepped
>>up to write a patch. There is also a run-time overhead.
>
>
> Yes.
>
>>> If I had known about Fortran's issues with alias analysis, I
>>> might have even included in a 6 page paper a reference to Fortran
>>> alias analysis -something like this:
>>
>>> " Fortran has similar problems with similar assumptions:
>>> "anything may happen: the program may appear to run normally,
>>> or produce incorrect answers, or behave unpredictably." [24]."
>>
>>In Fortran, the wording is clearer than C's weasel-word "undefined
>>behavior".
>
>
> Absolutely agree that "undefined behavior" is an awful concept.
> I think it is used to evade burden on the compilers for error checking and
> to evade plainly stating proposed limitations to C expressiveness.

However, the effect is the same, but it brings on many more
misunderstandings.

>>Code which does so is in violation of a "shall"
>>directive, so the program is erronous. This is not a violation
>>of a constraint (which are clearly labeled and numbered) so a
>>compiler is not required to diagnose it.
>>
>>Case closed.
>
>>>
>>>> > Since you bring it up, for me the way C originally handled
>>>> > integer overflow was sloppy and sometimes dangerous - it was an
>>>> > engineering tradeoff made to make fast code and simple compilation.
>>>> > BUT the ISO-C approach is mathematically incoherent and even more
>>>> > dangerous - because semantics is unpredictable.
>>>> Signed integer overflow is an error, period (the same in
>>>> Fortran as in C).
>>>> > Ironically, as C compilers muddied int arithmetic, processors
>>>> > became much better about native signed arithmetic. Mod 2^k 2s
>>>> > complement, which is native on the vast majority of modern
>>>> > processors is mathematically coherent even if it is hard to
>>>> > work with.
>>>> Very hard, and a source of errors...
>>>
>>> Programming is hard. Some languages have runtime to catch
>>> those errrors,
>>
>>Run-time checks to catch thinking errors in mod 2^n arithmetic?
>>I am amazed, please tell me what these are.
>
>
> You can, if you want, select ftrapv on both gcc and
> clang. This will catch overflows.

There are no overflows in 2^n arithmetic.

>
>>> and even in some C compilers we have an option for ftrapv. But
>>> there are tradeoffs. This is why Fortran uses floating point
>>> arithmetic even though it is a notorious source of errors.
>>
>>C also uses floating point, in case you had not noticed - the types
>>are called "float" and "double".
>
>
> It does for the same reason.

??

>
>>>> > But what we have in ISO C makes arithmetic depend on vagaries
>>>> > of the optimizer and produces paradoxes.
>>>> Ah, no. It means that an erroneous program gets random results,
>>>
>>> With modular arithmetic, or even saturating as you have on some
>>> processors, you do not get random results. You may not get the
>>> results you expect if you think 4 byte or even 8 or 16 byte "ints"
>>> can represent all of Z.
>>
>>You are confusing the C language with whatever happens on a
>>particular system. Might I point out section 5.1.2.3 of n2346.pdf:
>
>
> You are confusing your interpretation of C standard for laws of physics. I propose
> different semantics.

OK, so I understand that you want another language, not C.

> BTW: C overflow semantics are not described in the C standard at all. The standard
> leaves it up to the implementation.
>
>># The semantic descriptions in this document describe the behavior of
>># an abstract machine in which issues of optimization are irrelevant.
>>
>>The C standard is the specification for that abstract machine.
>>As long as you stick to that, you're reasonably safe (and you can
>>holler at compiler writers if you find bugs). If you insist on
>>peculiarities of a particular implementation... well, you violated
>>the contract, it's your fault.
>>
>
> And overflow is specifically stated to be undefined.


Click here to read the complete article
Re: Paper about ISO C

<06_9J.89851$YW.14858@fx05.iad>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: rocksolid2!i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx05.iad.POSTED!not-for-mail
From: ThatWoul...@thevillage.com (EricP)
User-Agent: Thunderbird 2.0.0.24 (Windows/20100228)
MIME-Version: 1.0
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me> <afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com> <3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com> <sk6s4a$9cm$1@dont-email.me> <1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com> <sk8jd2$v86$1@newsreader4.netcologne.de> <Q9U9J.190243$o45.179981@fx46.iad> <6f3a3f2c-c066-46fc-bd15-7e31ac1846f3n@googlegroups.com>
In-Reply-To: <6f3a3f2c-c066-46fc-bd15-7e31ac1846f3n@googlegroups.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 16
Message-ID: <06_9J.89851$YW.14858@fx05.iad>
X-Complaints-To: abuse@UsenetServer.com
NNTP-Posting-Date: Thu, 14 Oct 2021 17:50:52 UTC
Date: Thu, 14 Oct 2021 13:50:52 -0400
X-Received-Bytes: 1681
 by: EricP - Thu, 14 Oct 2021 17:50 UTC

MitchAlsup wrote:
> On Thursday, October 14, 2021 at 6:05:22 AM UTC-5, Branimir Maksimovic wrote:
>> Fortran is pre structured era, spagetti code. Good for
>> arrays, not mutch for anything else :P
>> Good luck with network code or parsing with FORTRAN :P
> <
> I lead a team that built a FORTRAN runtime library using nothing other
> than FORTRAN.

Ratfor was a structured language preprocessor by Brian Kernighan in 1974
who said it was "shamelessly stolen from the language C",
was written in Ratfor and spit out Fortran 66,
which when compiled processed the Ratfor.

Never used it myself.

Re: Paper about ISO C

<sk9r27$pa3$3@newsreader4.netcologne.de>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: rocksolid2!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-f01f-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, 14 Oct 2021 17:57:27 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <sk9r27$pa3$3@newsreader4.netcologne.de>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk8jd2$v86$1@newsreader4.netcologne.de> <Q9U9J.190243$o45.179981@fx46.iad>
<6f3a3f2c-c066-46fc-bd15-7e31ac1846f3n@googlegroups.com>
<06_9J.89851$YW.14858@fx05.iad>
Injection-Date: Thu, 14 Oct 2021 17:57:27 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-f01f-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:f01f:0:7285:c2ff:fe6c:992d";
logging-data="25923"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Thu, 14 Oct 2021 17:57 UTC

EricP <ThatWouldBeTelling@thevillage.com> schrieb:
> MitchAlsup wrote:
>> On Thursday, October 14, 2021 at 6:05:22 AM UTC-5, Branimir Maksimovic wrote:
>>> Fortran is pre structured era, spagetti code. Good for
>>> arrays, not mutch for anything else :P
>>> Good luck with network code or parsing with FORTRAN :P
>> <
>> I lead a team that built a FORTRAN runtime library using nothing other
>> than FORTRAN.
>
> Ratfor was a structured language preprocessor by Brian Kernighan in 1974
> who said it was "shamelessly stolen from the language C",
> was written in Ratfor and spit out Fortran 66,
> which when compiled processed the Ratfor.

It was actually used as prior art for IF/THEN/ELSE, or Fortran 77
might not even have gotten that.

For one of the inventors of C, Kernighan certainly had a lot of
contact with Fortran. I like the story that he wrote a version
of runoff for his PhD thesis (in pre-77 Fortran, no less) so
his was the first computer-printed PhD thesis at Princeton.

> Never used it myself.

Neither have I, when I started serious programming, Fortran 77
was already available.

Re: Paper about ISO C

<1db77bce-e119-4658-a6ee-148077edc8a1n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:620a:17a9:: with SMTP id ay41mr6091267qkb.452.1634235628164;
Thu, 14 Oct 2021 11:20:28 -0700 (PDT)
X-Received: by 2002:aca:ab56:: with SMTP id u83mr14900723oie.110.1634235627859;
Thu, 14 Oct 2021 11:20:27 -0700 (PDT)
Path: rocksolid2!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, 14 Oct 2021 11:20:27 -0700 (PDT)
In-Reply-To: <sk9qfi$pa3$2@newsreader4.netcologne.de>
Injection-Info: google-groups.googlegroups.com; posting-host=24.173.181.154; posting-account=jn4_9AoAAADlg7v8KtkkjWBduIrvz8VB
NNTP-Posting-Host: 24.173.181.154
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com> <3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me> <1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk8jd2$v86$1@newsreader4.netcologne.de> <9157851d-afcf-454a-908a-2e159fb1e3f2n@googlegroups.com>
<sk9j4v$lhk$1@newsreader4.netcologne.de> <e325b8a8-d8c9-41fa-ad49-10709a12da7an@googlegroups.com>
<sk9qfi$pa3$2@newsreader4.netcologne.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1db77bce-e119-4658-a6ee-148077edc8a1n@googlegroups.com>
Subject: Re: Paper about ISO C
From: victor.y...@gmail.com (Victor Yodaiken)
Injection-Date: Thu, 14 Oct 2021 18:20:28 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 41
 by: Victor Yodaiken - Thu, 14 Oct 2021 18:20 UTC

"Undefined behavior" does not mean "programming error" and never has.
One meaning is just something not specified explicitly in the standard.

----
If a “shall” or “shall not” requirement that appears outside of a constraint or
runtime-constraint is violated, the behavior is undefined. Undefined behavior
is otherwise indicated in this International Standard by the words “undefined
behavior” or by the omission
of any explicit definition of behavior. There is no difference in emphasis among
these three; they all describe “behavior that is undefined”.
----

Note: "or by the omission of any explicit definition of behavior.". What does pthread_create do? There
is no explicit definition in the C Standard. What does asm do? Same. What does mmap do? Same again.
What happens when device driver code initiates a DMA operation? Not one word in the standard.
It is impossible to write a serious C program without producing undefined behavior and, certainly,
implementations are permitted a wide range of action on encountering undefined behavior
An implementation that chooses, e.g. to implement signed arithmetic by delegating semantics to the target
processor would be conforming.

The theory that undefined behavior can be treated as impossible has very little basis in the C standard text. It is
a compiler implementation innovation.

This is basic. If you are confused about it, your interpretations of the C standard are not going to
make any sense at all.

Re: Paper about ISO C

<sk9tq8$ee$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: rocksolid2!news.neodome.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: cr88...@gmail.com (BGB)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Thu, 14 Oct 2021 13:44:21 -0500
Organization: A noiseless patient Spider
Lines: 158
Message-ID: <sk9tq8$ee$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk9ej9$fj9$1@dont-email.me>
<b230d3fe-324f-491e-9e70-5398f1b68b3cn@googlegroups.com>
<sk9n30$nm7$3@newsreader4.netcologne.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 14 Oct 2021 18:44:25 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="1da7da4ddb5e072361699b652fb4abec";
logging-data="462"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+QK3gjkgHqE9qO17Lsh1DG"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.2.0
Cancel-Lock: sha1:U5phqF2iHoSgjjinRclpvEMhy1o=
In-Reply-To: <sk9n30$nm7$3@newsreader4.netcologne.de>
Content-Language: en-US
 by: BGB - Thu, 14 Oct 2021 18:44 UTC

On 10/14/2021 11:49 AM, Thomas Koenig wrote:
> Victor Yodaiken <victor.yodaiken@gmail.com> schrieb:
>> On Thursday, October 14, 2021 at 9:24:43 AM UTC-5, David Brown wrote:
>>
>>> The standard has to provide the lowest common denominator - the most
>>> vague version of the language, with the most undefined behaviours and
>>> implementation-defined behaviours. It is then up to implementations to
>>> tighten these details as appropriate, or offer options for additional
>>> semantics.
>>>
>>
>> I disagree. Overuse of UB degrades the semantics of the language
>> and reduces its utility. The overhead in dealing with unpredictable
>> unsound optimizations is a serious drag on the utility of C.
>
> Let's called "undefined behavior" what it is - programming errors,
> and see how much your sentence makes sense then.
>

This would only be true IMO, if all of the "undefined behavior" cases
only represented things which could happen unintentionally, or which
otherwise did not serve any use.

Many of the common cases are things which have "perfectly reasonable"
behavior on most targets, and are themselves useful for writing
straightforward and performant code, but none the less fall outside the
scope of the C standard.

Eg:
Signed right shift;
Signed integer overflow;
Ability to cast and dereference pointers as
"whatever the hell one wants";
...

For general consistency, one might define:
Signed right shift is an arithmetic right shift;
Signed integer overflow is modular;
Pointers exist within a linear address space,
types have concrete sizes and representations;
Floating point types follow IEEE format,
with the same endianess as integer types;
...

Then, say, one defines several sub-models:
IP16 (int/pointer are 16 bits, long is 32 bits, long long is opt 64)
LP32 (int is 16 bits, long / pointer are 32 bits, long long is opt 64)
ILP32 (int/long/pointer are 32 bits, long long is 64 bits)
LLP64 (int / long are 32 bits, long long / pointer are 64 bits)
LP64 (int is 32 bits, long / long long / pointer are 64 bits)

So, eg:
IP16, 16-bit machines;
LP32, 16-bit, or 32 bit machines faking a 16-bit machine;
ILP32, 32-bit machines
...

Then, say, one allows a more restricted form of aliasing rules:
Dereferening a volatile pointer may alias with anything;
Any explicit cast and dereference operation may also alias;
...

In this case, one could gain some of the performance benefits of
strict-aliasing semantics, without them having the annoying property of
breaking code which is built on top of using pointer casts for
type-punning and similar.

Some secondary (likely more controversial) rules:
We can assume that the machine is little endian;
Or, maybe add official PP defines for machine endianess (*).
We can assume that shift operators are size-modular;
Eg: (x<<64)==x, for long-long and smaller.
The nominal type for array indexing is 'int';
...

Say, a machine using LP64 may have built-in defines like, say:
__ARCH_LP64__
__ARCH_LITTLE_ENDIAN__
...

Or if say, it is something like my RIL3 IR, which can compile code in a
sub-mode where it can be either ILP32 or LP64 and thus 'sizeof(long)'
and similar is not be known until later, this can be specified as well
via a define.

Maybe also define how C would behave on a machine with a 128-bit address
space.

Current thinking:
int/long/long long: Same sizes as in LP64
pointer: 128 bits
intptr_t / etc: also 128 bits

Might also specify 128-bit integer literals.

Maybe also a literal type suffix specifically for machine addresses /
pointers, ... This behaves like if one did the usual thing of using an
appropriate suffix for the specific machine and then cast it to 'void *'
or similar.

Say:
0xA0003F80C000P //or similar
Maps to the equivalent of:
(void *)0xA0003F80C000ULL

Though, need not map 1:1 to the integer representation on machines where
the logical mapping is not itself 1:1, say:
0x43219876CDEF123456789ABCP
Might map to:
(void *)0x000043219876CDEF0000123456789ABCUI128

Within the possible 96-bit address space extension (with the 0000 bits
still being used for dynamic type-tags and flags and similar).

Though, some of this depends on how I interpret pointer casts between
int128 and xptr types (whether it is a direct 1:1 cast, or whether the
cast shuffles the bits around so that the integer representation looks
like a linear 96 bit address, with 32 bits of tagging data in the
high-order bits).

Though, granted, this is with a funky default addressing scheme based
around 48-bit "quadrants" (1/4 petabyte), with everything above the
48-bit mark being addressed in terms of "quads".

Some of this is partly an artifact of trying to come up with ways to
implement this feature in a way which doesn't ruin timing (direct linear
96-bit address calculations are no-go; hence the scheme based on pairs
of 48 bit addresses).

Actually, if we have _BitInt(n), might also add that there is a way to
specify literal values of this type (vs, say, an implementation which
has huge integer types but no way to express huge integer literals).

....

More speculatively:
What if we also specify a format which can be used to specify things
like source files, library dependencies, ... in a C based project;
Which is not itself tied to a particular build-system or build tool (we
already have enough of these).

This could be sort of like a highly stripped down and minimal subset of
Makefile or CMake syntax, intended to be reasonably easy to parse and
generic.

Well, or someone could be a jerk and base the whole thing on MSBuild
syntax (XML based)...

....

Re: Paper about ISO C

<27a1814f-819f-4cb5-a818-ecc095bf3309n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:6214:70f:: with SMTP id b15mr7284658qvz.16.1634237617301;
Thu, 14 Oct 2021 11:53:37 -0700 (PDT)
X-Received: by 2002:a9d:764c:: with SMTP id o12mr4125710otl.129.1634237617093;
Thu, 14 Oct 2021 11:53:37 -0700 (PDT)
Path: rocksolid2!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, 14 Oct 2021 11:53:36 -0700 (PDT)
In-Reply-To: <sk9r27$pa3$3@newsreader4.netcologne.de>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:5574:8c85:ed4a:262f;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:5574:8c85:ed4a:262f
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com> <3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me> <1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk8jd2$v86$1@newsreader4.netcologne.de> <Q9U9J.190243$o45.179981@fx46.iad>
<6f3a3f2c-c066-46fc-bd15-7e31ac1846f3n@googlegroups.com> <06_9J.89851$YW.14858@fx05.iad>
<sk9r27$pa3$3@newsreader4.netcologne.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <27a1814f-819f-4cb5-a818-ecc095bf3309n@googlegroups.com>
Subject: Re: Paper about ISO C
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Thu, 14 Oct 2021 18:53:37 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 33
 by: MitchAlsup - Thu, 14 Oct 2021 18:53 UTC

On Thursday, October 14, 2021 at 12:57:30 PM UTC-5, Thomas Koenig wrote:
> EricP <ThatWould...@thevillage.com> schrieb:
> > MitchAlsup wrote:
> >> On Thursday, October 14, 2021 at 6:05:22 AM UTC-5, Branimir Maksimovic wrote:
> >>> Fortran is pre structured era, spagetti code. Good for
> >>> arrays, not mutch for anything else :P
> >>> Good luck with network code or parsing with FORTRAN :P
> >> <
> >> I lead a team that built a FORTRAN runtime library using nothing other
> >> than FORTRAN.
> >
> > Ratfor was a structured language preprocessor by Brian Kernighan in 1974
> > who said it was "shamelessly stolen from the language C",
> > was written in Ratfor and spit out Fortran 66,
> > which when compiled processed the Ratfor.
> It was actually used as prior art for IF/THEN/ELSE, or Fortran 77
> might not even have gotten that.
>
> For one of the inventors of C, Kernighan certainly had a lot of
> contact with Fortran. I like the story that he wrote a version
> of runoff for his PhD thesis (in pre-77 Fortran, no less) so
> his was the first computer-printed PhD thesis at Princeton.
<
I wrote a typesetting program n ALGOL on the 1108 for a
CMU programming class. The program was only about 30
lines of code.
>
> > Never used it myself.
>
> Neither have I, when I started serious programming, Fortran 77
> was already available.
<
F77 was the language and target for the runtime library I lead.
Negligibly different then the Watfiv I used at CMU.

Re: Paper about ISO C

<ac08e129-1f64-433c-99f3-e775b92f9c96n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ac8:584d:: with SMTP id h13mr8690068qth.267.1634237772896;
Thu, 14 Oct 2021 11:56:12 -0700 (PDT)
X-Received: by 2002:a9d:384:: with SMTP id f4mr3960086otf.94.1634237772473;
Thu, 14 Oct 2021 11:56:12 -0700 (PDT)
Path: rocksolid2!news.neodome.net!news.mixmin.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Thu, 14 Oct 2021 11:56:12 -0700 (PDT)
In-Reply-To: <1db77bce-e119-4658-a6ee-148077edc8a1n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:5574:8c85:ed4a:262f;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:5574:8c85:ed4a:262f
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com> <3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me> <1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk8jd2$v86$1@newsreader4.netcologne.de> <9157851d-afcf-454a-908a-2e159fb1e3f2n@googlegroups.com>
<sk9j4v$lhk$1@newsreader4.netcologne.de> <e325b8a8-d8c9-41fa-ad49-10709a12da7an@googlegroups.com>
<sk9qfi$pa3$2@newsreader4.netcologne.de> <1db77bce-e119-4658-a6ee-148077edc8a1n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ac08e129-1f64-433c-99f3-e775b92f9c96n@googlegroups.com>
Subject: Re: Paper about ISO C
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Thu, 14 Oct 2021 18:56:12 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: MitchAlsup - Thu, 14 Oct 2021 18:56 UTC

On Thursday, October 14, 2021 at 1:20:29 PM UTC-5, victor....@gmail.com wrote:
> "Undefined behavior" does not mean "programming error" and never has.
> One meaning is just something not specified explicitly in the standard.
>
> ----
> If a “shall” or “shall not” requirement that appears outside of a constraint or
> runtime-constraint is violated, the behavior is undefined. Undefined behavior
> is otherwise indicated in this International Standard by the words “undefined
> behavior” or by the omission
> of any explicit definition of behavior. There is no difference in emphasis among
> these three; they all describe “behavior that is undefined”.
> ----
>
> Note: "or by the omission of any explicit definition of behavior.". What does pthread_create do? There
> is no explicit definition in the C Standard. What does asm do? Same. What does mmap do? Same again.
> What happens when device driver code initiates a DMA operation? Not one word in the standard.
>
> It is impossible to write a serious C program without producing undefined behavior
<
The original UNIX 'cat' has undefined behavior ?!?!
all it does is copy an input stream to an output stream.
<
> and, certainly,
> implementations are permitted a wide range of action on encountering undefined behavior
> An implementation that chooses, e.g. to implement signed arithmetic by delegating semantics to the target
> processor would be conforming.
>
> The theory that undefined behavior can be treated as impossible has very little basis in the C standard text. It is
> a compiler implementation innovation.
>
> This is basic. If you are confused about it, your interpretations of the C standard are not going to
> make any sense at all.

Re: Paper about ISO C

<jwvzgrb4eks.fsf-monnier+comp.arch@gnu.org>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: rocksolid2!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: monn...@iro.umontreal.ca (Stefan Monnier)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Thu, 14 Oct 2021 15:19:28 -0400
Organization: A noiseless patient Spider
Lines: 56
Message-ID: <jwvzgrb4eks.fsf-monnier+comp.arch@gnu.org>
References: <sjni60$97d$1@dont-email.me> <sjnmcp$630$1@dont-email.me>
<ca22ba8c-2f32-4999-a2d0-edde18d97a24n@googlegroups.com>
<hiN7J.53059$3p3.5024@fx16.iad>
<9e23mg1uk377av16575v343v97f128bbe6@4ax.com>
<Gwh8J.222306$T_8.186929@fx48.iad>
<j6i3mg16rc2f6d99n7u64cmebnvq02d407@4ax.com>
<VCo8J.34131$dI3.21011@fx10.iad>
<i7e8mglr9g6bnpo7e481hs5svk134511ui@4ax.com>
<lt59J.204443$Kv2.41185@fx47.iad>
<v0fbmghm532adupmq66nqsq0fcjgvsgun9@4ax.com>
<sk4nqv$uqe$1@dont-email.me>
<hm6emg9kciblfri0kpp1fr76lbt0qm8pvn@4ax.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="876fa62b84669f1120f6e722f0175bae";
logging-data="31287"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18i5jcMOYx7O3YePm2tMJsi"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
Cancel-Lock: sha1:rVM2AnKc8kLKTx9QiCVM0NuX2Ak=
sha1:V+p4zCGpNO1lp2DH58Z+E0RWTKY=
 by: Stefan Monnier - Thu, 14 Oct 2021 19:19 UTC

George Neuner [2021-10-13 14:26:18] wrote:
> You can separate the marking flags so as not to have to /write/ to
> objects during marking, but you must scan every live object.

Indeed. Using separate flags can save you from modifying those many
cache lines and it can also reduce save you from accessing the cache
line storing an object when encountering a second reference to it.
This second effect is usually quite secondary, tho, since most objects
have typically only a single reference to them (as is well known from
ref-count schemes where the vast majority of ref-counts are 1).

> Sweep has to touch, at minimum, every dead object.

Some allocation schemes can keep the metadata modified during sweep
separately from the actual objects (typically some kind of bibop
allocation where each "page" has a bitmap keeping track of which object
is free).

That can reduce the amount of memory accessed during sweep to less than
what is accessed during mark.

> If you are using the GC normally, there almost always will be far more
> dead objects than live objects.

That's what you want ideally for a copying GC, indeed, but in my
experience this is rarely the case. Cases where I've seen that are for
the nurseries of generational GCs (where copying GCs are popular for
that reason).

If you have more dead objects than live objects, it means your GC
imposes an overhead of more than 100% (and if you have "far more" dead
objects, than it's even "far worse"). As mentioned, for the nursery of
a generational GC this is not a problem since the nursery is a small
fraction of the total heap anyway, but such an overhead over the whole
heap would be rather problematic (if it's not, then there's a high
chance that your program doesn't actually care about performance at all
anyway and any GC scheme would be fine as well).

Don't get me wrong: I love copying schemes and I do think they work very
well in most cases, but it doesn't come for free.

> Again, the assumption is that the live set is much smaller than the
> dead set. Which IS the case for most programs in GC'd languages.

I think this is not inherently true. Rather, it needs to be true for
the GC to work efficiently, so the GC itself is tweaked so as to try and
make it true more often, e.g. by using generations (or other partitioned
heap schemes) and using heuristics that try to guess which partition to
GC this cycle (hoping it will hold the higher fraction of dead objects).

But over the whole heap, we still want to try and minimize the
proportion of dead objects, since they are an undesirable overhead
(that may increase VM or cache pressure).

Stefan

Re: Paper about ISO C

<jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: monn...@iro.umontreal.ca (Stefan Monnier)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Thu, 14 Oct 2021 15:34:02 -0400
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk9ej9$fj9$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="876fa62b84669f1120f6e722f0175bae";
logging-data="31287"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+2ys0DvVLc3ed8v2vzMiDq"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
Cancel-Lock: sha1:zoArjtrXdLh6OeRWkpyfG5Os87E=
sha1:4TOsyCHiwwP0FCO3rgHdTKy/8Ys=
 by: Stefan Monnier - Thu, 14 Oct 2021 19:34 UTC

David Brown [2021-10-14 16:24:40] wrote:
> The standard has to provide the lowest common denominator - the most
> vague version of the language, with the most undefined behaviours and
> implementation-defined behaviours. It is then up to implementations to
> tighten these details as appropriate, or offer options for additional
> semantics.
>
> But programmers have to understand that the C language is what is
> described by the standards, and this is the default for compilers - if
> the C standards don't say what happens when you do X, then neither does
> the compiler.

There lies the problem: the standard is bound by the "lowest common
denominator" and then compilers in turn use this lower target, rather
than having an intermediate target which is made more precise by relying
on extra knowledge of the target system.

This has the side effect that if you take code which relies on having
a flat address space, it can't be used reliably even if you make sure
it's only used on systems with a flat address space.

[ I mean, yes, in practice, it can be used, but you can never be sure
it'll work: instead, you have to try it out, see where it breaks,
figure out which trick to use to prevent the undesired "optimization",
... until you decide that it experimentally seems to work well enough
for the current version of your compiler. ]

Maybe for `<` and `-` between pointers to unrelated objects, the
standard should say that this is not UB when used on a system with
a flat address space (and that while the exact return value is
implementation dependent, it obeys the usual rules of those operators).

Stefan

Re: Paper about ISO C

<jwvo87r4cmh.fsf-monnier+comp.arch@gnu.org>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: rocksolid2!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: monn...@iro.umontreal.ca (Stefan Monnier)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Thu, 14 Oct 2021 15:46:49 -0400
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <jwvo87r4cmh.fsf-monnier+comp.arch@gnu.org>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk9ej9$fj9$1@dont-email.me>
<jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="876fa62b84669f1120f6e722f0175bae";
logging-data="18242"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19bzSanPBRQZkd8YkuRUixJ"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
Cancel-Lock: sha1:tPf4PPNp1eO8PImgrPOC+H3Nj0c=
sha1:48wnJ/WS6RGaGLVA4Nddl/WNot8=
 by: Stefan Monnier - Thu, 14 Oct 2021 19:46 UTC

> Maybe for `<` and `-` between pointers to unrelated objects, the
> standard should say that this is not UB when used on a system with
> a flat address space (and that while the exact return value is
> implementation dependent, it obeys the usual rules of those operators).

Rather than "a system with a flat address space" I guess it would
instead introduce a notion of "class of target" (a bit like the standard
already distinguishes between hosted and non-hosted cases). After all,
a compiler on a system with a flat address space might very well decide
not to obey the above refinement (e.g. because it does its own
copying-GC internally, I'm thinking here of something like
a C interpreter) and thus choose a different "target class" than the one
that would be more naturally chosen for the target system.

Stefan

Re: Paper about ISO C

<86r1cnno7q.fsf@linuxsc.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Thu, 14 Oct 2021 17:09:13 -0700
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <86r1cnno7q.fsf@linuxsc.com>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me> <afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com> <3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com> <sk6s4a$9cm$1@dont-email.me> <1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com> <sk9ej9$fj9$1@dont-email.me> <b230d3fe-324f-491e-9e70-5398f1b68b3cn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="10a97aeccc616ae090cb32966ae60c7c";
logging-data="7109"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/sLGnOGWuttgN9BfLzIzwXocNT446wVw0="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:wP3XHAZMDhz01aqezRb7hYHivSg=
sha1:FzjLRc8F8Pl3bxqmKFLTRJVnU2A=
 by: Tim Rentsch - Fri, 15 Oct 2021 00:09 UTC

Victor Yodaiken <victor.yodaiken@gmail.com> writes:

> [...] GCC says that you can use unions for type puns (which I find
> awkward) although the standard does not.

The C standard says very plainly that type punning may be achieved
by means of union member access. Quoting 6.5.2.3, paragraph 3,
footnote 95, first sentence, from N1570

If the member used to read the contents of a union object is
not the same as the member last used to store a value in the
object, the appropriate part of the object representation of
the value is reinterpreted as an object representation in the
new type as described in 6.2.6 (a process sometimes called
"type punning").

Re: Paper about ISO C

<86mtnbnntg.fsf@linuxsc.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Thu, 14 Oct 2021 17:17:47 -0700
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <86mtnbnntg.fsf@linuxsc.com>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me> <afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com> <3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com> <sk6s4a$9cm$1@dont-email.me> <1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com> <sk8jd2$v86$1@newsreader4.netcologne.de> <Q9U9J.190243$o45.179981@fx46.iad> <6f3a3f2c-c066-46fc-bd15-7e31ac1846f3n@googlegroups.com> <06_9J.89851$YW.14858@fx05.iad> <sk9r27$pa3$3@newsreader4.netcologne.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="10a97aeccc616ae090cb32966ae60c7c";
logging-data="7109"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+by6w5b3OS1fdhndKpKUU5tDw6iI4Rj30="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:J13+PqiHC/PX35FndLKHlurhPHs=
sha1:Q5WQhcIGilMdzlv79zV+BNmU4Yc=
 by: Tim Rentsch - Fri, 15 Oct 2021 00:17 UTC

Thomas Koenig <tkoenig@netcologne.de> writes:

> For one of the inventors of C, Kernighan certainly had a lot of
> contact with Fortran. [...]

Kernighan is not one of the inventors of C. He worked with
Dennis Ritchie writing the book "The C Programming Language",
but that was years after C was developed, and he did not play
any role in inventing the language. Kernighan himself has
said this ("it's entirely Dennis Ritchie's work").

Re: ratfor, was Paper about ISO C

<skaika$1ssg$2@gal.iecc.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!not-for-mail
From: joh...@taugh.com (John Levine)
Newsgroups: comp.arch
Subject: Re: ratfor, was Paper about ISO C
Date: Fri, 15 Oct 2021 00:39:38 -0000 (UTC)
Organization: Taughannock Networks
Message-ID: <skaika$1ssg$2@gal.iecc.com>
References: <87fstdumxd.fsf@hotmail.com> <06_9J.89851$YW.14858@fx05.iad> <sk9r27$pa3$3@newsreader4.netcologne.de> <86mtnbnntg.fsf@linuxsc.com>
Injection-Date: Fri, 15 Oct 2021 00:39:38 -0000 (UTC)
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970";
logging-data="62352"; mail-complaints-to="abuse@iecc.com"
In-Reply-To: <87fstdumxd.fsf@hotmail.com> <06_9J.89851$YW.14858@fx05.iad> <sk9r27$pa3$3@newsreader4.netcologne.de> <86mtnbnntg.fsf@linuxsc.com>
Cleverness: some
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: johnl@iecc.com (John Levine)
 by: John Levine - Fri, 15 Oct 2021 00:39 UTC

According to Tim Rentsch <tr.17687@z991.linuxsc.com>:
>Thomas Koenig <tkoenig@netcologne.de> writes:
>
>> For one of the inventors of C, Kernighan certainly had a lot of
>> contact with Fortran. [...]
>
>Kernighan is not one of the inventors of C. He worked with
>Dennis Ritchie writing the book "The C Programming Language",
>but that was years after C was developed, and he did not play
>any role in inventing the language. Kernighan himself has
>said this ("it's entirely Dennis Ritchie's work").

In the 1960s and early 1970s everyone in academic computer
science knew Fortran even if we didn't use it much. It was
the language that could, with some effort, run on anything.

I used Ratfor a little. I got it running on our PDP-10 at Yale
and arranged to pass through the line sequence numbers so that
errors from the Fortran compiler would match the ones in the
original source. I think I wrote the glue in bliss36.

--
Regards,
John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies",
Please consider the environment before reading this e-mail. https://jl.ly

Re: Paper about ISO C

<86ilxznlxi.fsf@linuxsc.com>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: rocksolid2!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Thu, 14 Oct 2021 17:58:33 -0700
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <86ilxznlxi.fsf@linuxsc.com>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me> <afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com> <sjugcv$jio$1@dont-email.me> <cb6bbb41-398f-4e2a-9a19-08bc4582b291n@googlegroups.com> <sk261q$me9$1@newsreader4.netcologne.de> <86zgrentbk.fsf@linuxsc.com> <3xC9J.89292$YW.52387@fx05.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="10a97aeccc616ae090cb32966ae60c7c";
logging-data="7109"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/TUDlpNOmccCaUZV3ydREi9v3/nJYgIbw="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:iqZd0ixqxAqRYVzWfKTkzUo8lHs=
sha1:y2SaPn8Ins3ocB9U0IY+EZFUkpU=
 by: Tim Rentsch - Fri, 15 Oct 2021 00:58 UTC

EricP <ThatWouldBeTelling@thevillage.com> writes:

> Tim Rentsch wrote:
>
>> Thomas Koenig <tkoenig@netcologne.de> writes:
>>
>>> Victor Yodaiken <victor.yodaiken@gmail.com> schrieb:
>>>
>>>> Can you cast a pointer to a different type? Sure.
>>>>
>>>> Can you dereference it?
>>>
>>> No.
>>
>> This statement is wrong, or at best much overstated. There are
>> plenty of situations where a C pointer value converted to a
>> different type may be safely and portably dereferenced.
>> Certainly that isn't always true, but it isn't always false
>> either.
>
> The problem is not accessing memory through a cast pointer. It is
> that according to C's rules for TBAA Typed Based Alias Analysis
> the optimizer is not required to recognize that accesses through
> different pointer types may be to the same memory location. [...]

My statement about safe and portable dereferencing includes
observing the boundaries of C's effective type rules.

(Note that "effective type" is the term used in the C standard
itself, not "strict aliasing" or "type based alias analysis",
even though it is common for people to use the latter terms when
what they are talking about are implications of C's effective
type rules.)

Re: Paper about ISO C

<skb0ii$d2j$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: rocksolid2!news.neodome.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ggt...@yahoo.com (Brett)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Fri, 15 Oct 2021 04:37:38 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <skb0ii$d2j$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com>
<sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<sjugcv$jio$1@dont-email.me>
<cb6bbb41-398f-4e2a-9a19-08bc4582b291n@googlegroups.com>
<sk437c$672$1@dont-email.me>
<0d336dad-0078-4783-9d13-635d1d061704n@googlegroups.com>
<f94c96c4-af61-4a60-b182-db213690c340n@googlegroups.com>
<C7q9J.45174$tA2.43354@fx02.iad>
<sk5cp7$26i$1@dont-email.me>
<apr9J.205378$Kv2.138883@fx47.iad>
<sk5ngm$og9$1@dont-email.me>
<_ox9J.87698$ol1.33401@fx42.iad>
<sk6ok2$22b$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 15 Oct 2021 04:37:38 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="1683350ea3241b12b40ed7574a99925d";
logging-data="13395"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19r1sb+9w1OsUHIMC6l/Cs8"
User-Agent: NewsTap/5.5 (iPad)
Cancel-Lock: sha1:cV0cwkgBCNeYWsjk9KHwrPOgHi8=
sha1:X1auhYEAm6SUw40CfKD+jN3RhpI=
 by: Brett - Fri, 15 Oct 2021 04:37 UTC

David Brown <david.brown@hesbynett.no> wrote:
> On 13/10/2021 11:11, Branimir Maksimovic wrote:
>> On 2021-10-13, Stephen Fuld <sfuld@alumni.cmu.edu.invalid> wrote:
>>> On 10/12/2021 7:21 PM, Branimir Maksimovic wrote:
>>>> On 2021-10-13, Stephen Fuld <sfuld@alumni.cmu.edu.invalid> wrote:
>>>>> To me, the big advantage of Ada (it's a woman's name, not an acronym -
>>>>> hence not all caps) is that its syntax makes it easier to write correct
>>>>> programs, and harder, though of course not impossible, to make the kind
>>>>> of errors this thread has been talking about.
>>>>>
>>>>> But others here are far more qualified to discuss this than I am.
>>>>>
>>>> OK, I'll try it, it, but on macOS I can't have compiler, let alone
>>>> IDE support :P
>>>
>>> Again, others are more qualified than I am to comment, but it appears
>>> that GNAT (GNU Ada compiler) is available on MacOS.
>>>
>>
>> Yes, but is only for x86, does not builds for my M1.
>> Interrestingly except gforth (without extensions)
>> there is no forth for M1, as well.
>
> I think that is mainly due to Apple's determination to stop people using
> Apple devices for any development other than Apple applications using
> Apple's tools and paying Apple's fees (for whatever they can get away
> with).

XCode is a free download.

> I can appreciate that an M1 machine gives you a lot of
> processing power in a small and low-power device, but they seem to be
> competing with Windows in their battle to make programmers' and small
> developers' lives as inconvenient as possible.
>
> Maybe they'll make an Ada front-end to clang, and call it "gnat" to
> confuse their users like they did with their C compiler.

Re: Paper about ISO C

<skb6bm$o1c$1@newsreader4.netcologne.de>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!4.us.feeder.erje.net!2.eu.feeder.erje.net!feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-f01f-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, 15 Oct 2021 06:16:22 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <skb6bm$o1c$1@newsreader4.netcologne.de>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk9ej9$fj9$1@dont-email.me> <jwvtuhj4dlq.fsf-monnier+comp.arch@gnu.org>
<jwvo87r4cmh.fsf-monnier+comp.arch@gnu.org>
Injection-Date: Fri, 15 Oct 2021 06:16:22 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-f01f-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:f01f:0:7285:c2ff:fe6c:992d";
logging-data="24620"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Fri, 15 Oct 2021 06:16 UTC

Stefan Monnier <monnier@iro.umontreal.ca> schrieb:
>> Maybe for `<` and `-` between pointers to unrelated objects, the
>> standard should say that this is not UB when used on a system with
>> a flat address space (and that while the exact return value is
>> implementation dependent, it obeys the usual rules of those operators).
>
> Rather than "a system with a flat address space" I guess it would
> instead introduce a notion of "class of target" (a bit like the standard
> already distinguishes between hosted and non-hosted cases). After all,
> a compiler on a system with a flat address space might very well decide
> not to obey the above refinement (e.g. because it does its own
> copying-GC internally, I'm thinking here of something like
> a C interpreter) and thus choose a different "target class" than the one
> that would be more naturally chosen for the target system.

So, a pointer would be a handle instead of a memory address?

I don't see offhand how that would work with pointer arithmetic
(which is central to C).

Re: Paper about ISO C

<skb6vc$o1c$2@newsreader4.netcologne.de>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: rocksolid2!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-f01f-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, 15 Oct 2021 06:26:52 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <skb6vc$o1c$2@newsreader4.netcologne.de>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk9ej9$fj9$1@dont-email.me>
<b230d3fe-324f-491e-9e70-5398f1b68b3cn@googlegroups.com>
<sk9n30$nm7$3@newsreader4.netcologne.de> <sk9tq8$ee$1@dont-email.me>
Injection-Date: Fri, 15 Oct 2021 06:26:52 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-f01f-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:f01f:0:7285:c2ff:fe6c:992d";
logging-data="24620"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Fri, 15 Oct 2021 06:26 UTC

BGB <cr88192@gmail.com> schrieb:
> On 10/14/2021 11:49 AM, Thomas Koenig wrote:
>> Victor Yodaiken <victor.yodaiken@gmail.com> schrieb:
>>> On Thursday, October 14, 2021 at 9:24:43 AM UTC-5, David Brown wrote:
>>>
>>>> The standard has to provide the lowest common denominator - the most
>>>> vague version of the language, with the most undefined behaviours and
>>>> implementation-defined behaviours. It is then up to implementations to
>>>> tighten these details as appropriate, or offer options for additional
>>>> semantics.
>>>>
>>>
>>> I disagree. Overuse of UB degrades the semantics of the language
>>> and reduces its utility. The overhead in dealing with unpredictable
>>> unsound optimizations is a serious drag on the utility of C.
>>
>> Let's called "undefined behavior" what it is - programming errors,
>> and see how much your sentence makes sense then.
>>
>
> This would only be true IMO, if all of the "undefined behavior" cases
> only represented things which could happen unintentionally, or which
> otherwise did not serve any use.
>
> Many of the common cases are things which have "perfectly reasonable"
> behavior on most targets, and are themselves useful for writing
> straightforward and performant code, but none the less fall outside the
> scope of the C standard.

In this case, they need to be documented in the compiler you use
(if you use your own, you are of course free to do anything :-)

This will lock the code into that particular compiler, or into a
set of compilers which happen to support the same feature. IMHO,
this is bad. Compiler vendors who manage to lock their customers
into their product to generate additional revenue will probably
have a different opinion.

>
>
> Eg:
> Signed right shift;
> Signed integer overflow;

That is something that I do not understand.

C has perfectly good unsigned integers. Instead of (assuming 32-bit
ints here)

int i;
....
i = i >> 1;

what's wrong with

i = ((unsigned int) i) >> 1;

or

i = (((unsigned int) i) >> 1) | (((unsigned int) i) & (1u << 31));

thus telling the compiler exactly what it should do with the sign
bit, and being portable at the same time? If you don't like to
write it out, put it in a macro or a static inline function in a
header somewhere (better type-safety that way), and you're done.

> Ability to cast and dereference pointers as
> "whatever the hell one wants";

"cast" using memcpy to make your intentions clear to the compiler.

Re: Paper about ISO C

<skbbpa$imo$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: rocksolid2!news.neodome.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: cr88...@gmail.com (BGB)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Fri, 15 Oct 2021 02:48:54 -0500
Organization: A noiseless patient Spider
Lines: 187
Message-ID: <skbbpa$imo$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk9ej9$fj9$1@dont-email.me>
<b230d3fe-324f-491e-9e70-5398f1b68b3cn@googlegroups.com>
<sk9n30$nm7$3@newsreader4.netcologne.de> <sk9tq8$ee$1@dont-email.me>
<skb6vc$o1c$2@newsreader4.netcologne.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 15 Oct 2021 07:48:58 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="db3a39ad9688d260b873ea3250492723";
logging-data="19160"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/vSCNejIdaCYPMBHVsTdr4"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.2.0
Cancel-Lock: sha1:f/Vr9KvF4Keq5JHeSC4cjg1FMvw=
In-Reply-To: <skb6vc$o1c$2@newsreader4.netcologne.de>
Content-Language: en-US
 by: BGB - Fri, 15 Oct 2021 07:48 UTC

On 10/15/2021 1:26 AM, Thomas Koenig wrote:
> BGB <cr88192@gmail.com> schrieb:
>> On 10/14/2021 11:49 AM, Thomas Koenig wrote:
>>> Victor Yodaiken <victor.yodaiken@gmail.com> schrieb:
>>>> On Thursday, October 14, 2021 at 9:24:43 AM UTC-5, David Brown wrote:
>>>>
>>>>> The standard has to provide the lowest common denominator - the most
>>>>> vague version of the language, with the most undefined behaviours and
>>>>> implementation-defined behaviours. It is then up to implementations to
>>>>> tighten these details as appropriate, or offer options for additional
>>>>> semantics.
>>>>>
>>>>
>>>> I disagree. Overuse of UB degrades the semantics of the language
>>>> and reduces its utility. The overhead in dealing with unpredictable
>>>> unsound optimizations is a serious drag on the utility of C.
>>>
>>> Let's called "undefined behavior" what it is - programming errors,
>>> and see how much your sentence makes sense then.
>>>
>>
>> This would only be true IMO, if all of the "undefined behavior" cases
>> only represented things which could happen unintentionally, or which
>> otherwise did not serve any use.
>>
>> Many of the common cases are things which have "perfectly reasonable"
>> behavior on most targets, and are themselves useful for writing
>> straightforward and performant code, but none the less fall outside the
>> scope of the C standard.
>
> In this case, they need to be documented in the compiler you use
> (if you use your own, you are of course free to do anything :-)
>
> This will lock the code into that particular compiler, or into a
> set of compilers which happen to support the same feature. IMHO,
> this is bad. Compiler vendors who manage to lock their customers
> into their product to generate additional revenue will probably
> have a different opinion.
>

Most of this same stuff works on existing compilers as-is.

Eg, one can write code using many of the rules I described, throw it at
MSVC or similar, and it just magically works.

A lot of this also works with GCC and Clang, with the main exception
being issues with strict aliasing (eg, needing "-fno-strict-aliasing"
and similar).

Some of us would prefer if "-fno-strict-aliasing" was the default, and
"-fstrict-aliasing" was left more for those who like to live a little
more dangerously...

>>
>>
>> Eg:
>> Signed right shift;
>> Signed integer overflow;
>
> That is something that I do not understand.
>
> C has perfectly good unsigned integers. Instead of (assuming 32-bit
> ints here)
>
> int i;
> ...
> i = i >> 1;
>
> what's wrong with
>
> i = ((unsigned int) i) >> 1;
>
> or
>
> i = (((unsigned int) i) >> 1) | (((unsigned int) i) & (1u << 31));
>
> thus telling the compiler exactly what it should do with the sign
> bit, and being portable at the same time? If you don't like to
> write it out, put it in a macro or a static inline function in a
> header somewhere (better type-safety that way), and you're done.
>

This requires heavy lifting from the compiler to realize that this
convoluted mess represents an arithmetic shift.

It is easier, for both normal programmers and the compiler implementers,
to declare that signed right shift is an arithmetic shift.

It is like asking people to use byte operations and shifts to read
values. Some compilers can figure it out (and turn it into a plain
load), while some others will give byte operations and shifts.

>> Ability to cast and dereference pointers as
>> "whatever the hell one wants";
>
> "cast" using memcpy to make your intentions clear to the compiler.
>

It depends on the compiler being clever to make it "not suck" (eg: turn
the memcpy call into a register operation or similar).

So, if the compiler is clever, it works.
But, if the compiler is not as clever and tries to do a memory copy
operation (or, worse, actually calls memcpy), then it sucks...

It is also a lot more awkward to type than (ab)using the use of pointer
casts and dereferencing.

The main tradeoff is that one can't use strict aliasing semantics, but
then it is notable that a number of projects explicitly disable
strict-aliasing on compilers which use it.

And, some other compilers have opted instead against using strict
aliasing by default. Granted, one of these compilers also didn't bother
adding any C99 features for well over a decade, and even then just kinda
half-assed it.

Also, this:
https://www.godbolt.org/z/Wqz99fK11

Or (with MSVC):
long long a, b;
a=30;
memcpy(&b, &a, sizeof(long long));
return b;
Becomes:
sub rsp, 40 ; 00000028H
mov r8d, 8
mov QWORD PTR a$[rsp], 30
lea rdx, QWORD PTR a$[rsp]
lea rcx, QWORD PTR b$[rsp]
call memcpy
mov eax, DWORD PTR b$[rsp]
add rsp, 40 ; 00000028H
ret 0

Note the:
call memcpy

Or, as can be paraphrased:
Don't do this sort of thing with MSVC; it kinda risks suck...

One can then argue:
"Well, /O2 makes it not suck, why not just use /O2?"

But, "/O2" is itself a tradeoff, it also enables a bunch of wacky
auto-vectorization stuff which is at times prone to make the program
slower than with "/O1".

Also, some older versions (sadly, "godbolt.org" only has newer MSVC
versions), were prone to transform it into a "similarly awful" sequence,
namely setting up for and using "REP MOVSB".

Now, what if we use a casts and dereferencing:
long long a, b;
a=30;
*(long long *)(&b)=*(long long *)(&a);
return b;
We get:
mov eax, 30
ret 0

Or, IOW, MSVC is a lot more clever about pointer operations.
Granted, this does still respect the type system.

What if we actually type pun:
double f;
long long a, b;
f=30;
*(long long *)(&b)=*(long long *)(&f);
return b;
We get:
movsd xmm0, QWORD PTR __real@403e000000000000
movsd QWORD PTR b$[rsp], xmm0
mov eax, DWORD PTR b$[rsp]
ret 0

But, meh, whatever, good enough...
At least it is better than a function call to "memcpy"...

Re: Paper about ISO C

<dAbaJ.185915$rl3.103818@fx45.iad>

  copy mid

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

  copy link   Newsgroups: comp.arch
Path: rocksolid2!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx45.iad.POSTED!not-for-mail
Newsgroups: comp.arch
From: branimir...@icloud.com (Branimir Maksimovic)
Subject: Re: Paper about ISO C
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<afb9352d-8ba7-4521-b741-280e0206e255n@googlegroups.com>
<3a350cfe-971c-4042-9171-9ec2516cdf2bn@googlegroups.com>
<sk6s4a$9cm$1@dont-email.me>
<1ed391dc-0d1d-4069-96d8-e83acbe01ba5n@googlegroups.com>
<sk8jd2$v86$1@newsreader4.netcologne.de> <Q9U9J.190243$o45.179981@fx46.iad>
<isqi6lFakk2U1@mid.individual.net>
User-Agent: slrn/1.0.3 (Darwin)
Lines: 13
Message-ID: <dAbaJ.185915$rl3.103818@fx45.iad>
X-Complaints-To: abuse@usenet-news.net
NNTP-Posting-Date: Fri, 15 Oct 2021 09:10:33 UTC
Organization: usenet-news.net
Date: Fri, 15 Oct 2021 09:10:33 GMT
X-Received-Bytes: 1274
 by: Branimir Maksimovic - Fri, 15 Oct 2021 09:10 UTC

On 2021-10-14, Niklas Holsti <niklas.holsti@tidorum.invalid> wrote:
>> Fortran is pre structured era, spagetti code.
>
>
> Fortran has evolved. Look at current Fortran, not at something from over
> half a century ago.
Well, it's not FORTRAN anymore then :P

--

7-77-777
Evil Sinner!
with software, you repeat same experiment, expecting different results...

Pages:123456789101112131415161718192021222324252627282930313233
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor