Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Witch! Witch! They'll burn ya! -- Hag, "Tomorrow is Yesterday", stardate unknown


devel / comp.lang.c / Re: you think rust may outthrone c?

SubjectAuthor
* you think rust may outthrone c?fir
`* Re: you think rust may outthrone c?Blue-Maned_Hawk
 +- Re: you think rust may outthrone c?jak
 +* Re: you think rust may outthrone c?fir
 |`- Re: you think rust may outthrone c?fir
 +* Re: you think rust may outthrone c?rek2 hispagatos
 |`* Re: you think rust may outthrone c?Kaz Kylheku
 | `* Re: you think rust may outthrone c?Kalevi Kolttonen
 |  +* Re: you think rust may outthrone c?Scott Lurndal
 |  |`* Re: you think rust may outthrone c?Kalevi Kolttonen
 |  | +- Re: you think rust may outthrone c?Kaz Kylheku
 |  | +* Re: you think rust may outthrone c?Bart
 |  | |`* Re: you think rust may outthrone c?Kalevi Kolttonen
 |  | | +* Re: you think rust may outthrone c?Bart
 |  | | |+* Re: you think rust may outthrone c?Kalevi Kolttonen
 |  | | ||`* Re: you think rust may outthrone c?Kaz Kylheku
 |  | | || `- Re: you think rust may outthrone c?Kalevi Kolttonen
 |  | | |`* Re: you think rust may outthrone c?David Brown
 |  | | | `* Re: you think rust may outthrone c?Kalevi Kolttonen
 |  | | |  +* Re: you think rust may outthrone c?David Brown
 |  | | |  |`* Re: you think rust may outthrone c?Kaz Kylheku
 |  | | |  | `- Re: you think rust may outthrone c?Kalevi Kolttonen
 |  | | |  `* Re: you think rust may outthrone c?Kaz Kylheku
 |  | | |   `* Re: you think rust may outthrone c?Kalevi Kolttonen
 |  | | |    `* Re: you think rust may outthrone c?David Brown
 |  | | |     +* Re: you think rust may outthrone c?Scott Lurndal
 |  | | |     |`- Re: you think rust may outthrone c?Keith Thompson
 |  | | |     `* Re: you think rust may outthrone c?Keith Thompson
 |  | | |      +- Re: you think rust may outthrone c?David Brown
 |  | | |      `* Re: you think rust may outthrone c?Malcolm McLean
 |  | | |       `* Re: you think rust may outthrone c?David Brown
 |  | | |        `* Re: you think rust may outthrone c?Malcolm McLean
 |  | | |         `* Re: you think rust may outthrone c?David Brown
 |  | | |          +- Re: you think rust may outthrone c?fir
 |  | | |          +* Re: you think rust may outthrone c?fir
 |  | | |          |`* Re: you think rust may outthrone c?fir
 |  | | |          | `- Re: you think rust may outthrone c?fir
 |  | | |          `* Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |           `* Re: you think rust may outthrone c?Bart
 |  | | |            +* Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |            |`* Re: you think rust may outthrone c?Malcolm McLean
 |  | | |            | +* Re: you think rust may outthrone c?David Brown
 |  | | |            | |+* Re: you think rust may outthrone c?Malcolm McLean
 |  | | |            | ||+* Re: you think rust may outthrone c?David Brown
 |  | | |            | |||+* Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |            | ||||`* Re: you think rust may outthrone c?Tim Rentsch
 |  | | |            | |||| `- Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |            | |||`* Re: you think rust may outthrone c?Bart
 |  | | |            | ||| +- Re: you think rust may outthrone c?Malcolm McLean
 |  | | |            | ||| `- Re: you think rust may outthrone c?David Brown
 |  | | |            | ||`- Re: you think rust may outthrone c?Scott Lurndal
 |  | | |            | |`* Re: you think rust may outthrone c?Kaz Kylheku
 |  | | |            | | +- Re: you think rust may outthrone c?David Brown
 |  | | |            | | `* Re: you think rust may outthrone c?jak
 |  | | |            | |  `* Re: you think rust may outthrone c?Kaz Kylheku
 |  | | |            | |   +- Re: you think rust may outthrone c?jak
 |  | | |            | |   `- Re: you think rust may outthrone c?Tim Rentsch
 |  | | |            | `* Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |            |  `* Re: you think rust may outthrone c?Malcolm McLean
 |  | | |            |   +- Re: you think rust may outthrone c?David Brown
 |  | | |            |   `- Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |            `* Re: you think rust may outthrone c?David Brown
 |  | | |             `* Re: you think rust may outthrone c?fir
 |  | | |              +* Re: you think rust may outthrone c?Chris M. Thomasson
 |  | | |              |`* Re: you think rust may outthrone c?David Brown
 |  | | |              | +* Re: you think rust may outthrone c?Chris M. Thomasson
 |  | | |              | |+* Re: you think rust may outthrone c?Chris M. Thomasson
 |  | | |              | ||+- Re: you think rust may outthrone c?Chris M. Thomasson
 |  | | |              | ||+* Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |              | |||`- Re: you think rust may outthrone c?Chris M. Thomasson
 |  | | |              | ||`- Re: you think rust may outthrone c?fir
 |  | | |              | |`- Re: you think rust may outthrone c?Bart
 |  | | |              | `- Re: you think rust may outthrone c?Chris M. Thomasson
 |  | | |              `* Re: you think rust may outthrone c?fir
 |  | | |               `* Re: you think rust may outthrone c?Bart
 |  | | |                +* Re: you think rust may outthrone c?Keith Thompson
 |  | | |                |+* Re: you think rust may outthrone c?Bart
 |  | | |                ||+* Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |                |||`* Re: you think rust may outthrone c?Bart
 |  | | |                ||| +- Re: you think rust may outthrone c?Kaz Kylheku
 |  | | |                ||| +* Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |                ||| |+* Re: you think rust may outthrone c?David Brown
 |  | | |                ||| ||+- Re: you think rust may outthrone c?Bart
 |  | | |                ||| ||`* Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |                ||| || `* Re: you think rust may outthrone c?David Brown
 |  | | |                ||| ||  `* Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |                ||| ||   +* Re: you think rust may outthrone c?David Brown
 |  | | |                ||| ||   |`* Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |                ||| ||   | `* Re: you think rust may outthrone c?David Brown
 |  | | |                ||| ||   |  `- Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |                ||| ||   `* Re: you think rust may outthrone c?Kaz Kylheku
 |  | | |                ||| ||    `- Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |                ||| |+* Re: you think rust may outthrone c?Bart
 |  | | |                ||| ||+* Re: you think rust may outthrone c?Ike Naar
 |  | | |                ||| |||`- Re: you think rust may outthrone c?Bart
 |  | | |                ||| ||+* Re: you think rust may outthrone c?David Brown
 |  | | |                ||| |||`* Re: you think rust may outthrone c?Bart
 |  | | |                ||| ||| `- Re: you think rust may outthrone c?David Brown
 |  | | |                ||| ||`* Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |                ||| || +- Re: you think rust may outthrone c?Kaz Kylheku
 |  | | |                ||| || +* Re: you think rust may outthrone c?Malcolm McLean
 |  | | |                ||| || `* Re: you think rust may outthrone c?Bart
 |  | | |                ||| |`* Re: you think rust may outthrone c?Scott Lurndal
 |  | | |                ||| `* Re: you think rust may outthrone c?Keith Thompson
 |  | | |                ||`- Re: you think rust may outthrone c?Keith Thompson
 |  | | |                |`* Re: you think rust may outthrone c?Kaz Kylheku
 |  | | |                `* Re: you think rust may outthrone c?fir
 |  | | +* Yeah, C is harder than many programming languages. Your point? (Was: you think Kenny McCormack
 |  | | +* Re: you think rust may outthrone c?Po Lu
 |  | | `* Re: you think rust may outthrone c?Kaz Kylheku
 |  | +* Re: you think rust may outthrone c?David Brown
 |  | `- Re: you think rust may outthrone c?Po Lu
 |  `* Re: you think rust may outthrone c?Anton Shepelev
 `* Re: you think rust may outthrone c?Bonita Montero

Pages:123456789101112131415161718192021222324252627282930313233343536373839
Re: you think rust may outthrone c?

<u9b4se$2m3vt$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26363&group=comp.lang.c#26363

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 20 Jul 2023 12:13:19 +0100
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <u9b4se$2m3vt$2@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<87sf9niqb6.fsf@bsb.me.uk> <u923gr$tf08$1@dont-email.me>
<u92mms$12tmp$1@dont-email.me>
<5fbef78e-14f8-43c4-afaf-17fa5bad12bdn@googlegroups.com>
<b54f60b1-6db7-4ecc-a1f6-b03c78c291een@googlegroups.com>
<u94eb1$1c2vr$1@dont-email.me> <874jm2tbkt.fsf@nosuchdomain.example.com>
<u94hip$1cdbp$1@dont-email.me> <87lefeukpy.fsf@bsb.me.uk>
<u94pch$1dpd6$1@dont-email.me> <87edl6uf9y.fsf@bsb.me.uk>
<u95rn3$1k9hq$1@dont-email.me> <87r0p4tyx4.fsf@bsb.me.uk>
<u98g5n$2469a$1@dont-email.me> <u98rs9$26ae9$1@dont-email.me>
<87mszrsx6z.fsf@bsb.me.uk> <u99alq$292ke$1@dont-email.me>
<87wmyvr9kg.fsf@bsb.me.uk> <87fs5jseuv.fsf@nosuchdomain.example.com>
<20230719160546.668@kylheku.com> <87bkg7s5zt.fsf@nosuchdomain.example.com>
<b5f1c671-ed9c-4bc4-b899-552d71335037n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 20 Jul 2023 11:13:18 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2e13e49741e984015742a684e1703412";
logging-data="2822141"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19lEt+VH0jpTaerIpf+imQnTr0vtrCxu1M="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:f2B8G6uYaIBrjRG3Y6mXIq0vL7A=
In-Reply-To: <b5f1c671-ed9c-4bc4-b899-552d71335037n@googlegroups.com>
 by: Bart - Thu, 20 Jul 2023 11:13 UTC

On 20/07/2023 09:46, Malcolm McLean wrote:

> One machine I worked on (the Nintendo 64) had nine bits per byte. However
> the C compiler and most assembly instructions only used 8 bits.The 9th
> bit was used by the GPU and you could access it using special machine
> instructions.
> It wasn't used for trap representations of course. But 32 logical bits doesn't necessarily
> means 32 physical bits.

The first machine I made (based on 8-bit Z80), used 6-bit bytes in parts
of the memory used for the text display buffer (because I was too tight
to buy two extra 1Kx1 chips to make it 8).

And 4-bit bytes in the memory used for the graphical display (to
simplify access when used in greyscale mode: each of the 128x128 pixels
had its own address).

I can't remember the details, but I'd hope the unused bits were pulled
down to appear as zeros, otherwise they would be read as 1s - maybe.

Re: you think rust may outthrone c?

<2c1804d7-256e-4e3a-aa8e-d2cf4cea82can@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26364&group=comp.lang.c#26364

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:1713:b0:403:aa87:d220 with SMTP id h19-20020a05622a171300b00403aa87d220mr99241qtk.0.1689856752317; Thu, 20 Jul 2023 05:39:12 -0700 (PDT)
X-Received: by 2002:a05:6870:c7ae:b0:1b0:41da:daa8 with SMTP id dy46-20020a056870c7ae00b001b041dadaa8mr2071868oab.1.1689856752101; Thu, 20 Jul 2023 05:39:12 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!69.80.99.14.MISMATCH!border-1.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Thu, 20 Jul 2023 05:39:11 -0700 (PDT)
In-Reply-To: <u9avim$2l5mt$3@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2003:f7:1f3a:cbf2:408:5ed8:7d21:ba3; posting-account=AqNUYgoAAADmkK2pN-RKms8sww57W0Iw
NNTP-Posting-Host: 2003:f7:1f3a:cbf2:408:5ed8:7d21:ba3
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com> <u90c0s$nr2u$1@dont-email.me> <0ff5dfe1-de32-4dae-872e-5401a3c04c97n@googlegroups.com> <u90u5r$pnad$1@dont-email.me> <87sf9niqb6.fsf@bsb.me.uk> <u923gr$tf08$1@dont-email.me> <u92mms$12tmp$1@dont-email.me> <5fbef78e-14f8-43c4-afaf-17fa5bad12bdn@googlegroups.com> <b54f60b1-6db7-4ecc-a1f6-b03c78c291een@googlegroups.com> <u94eb1$1c2vr$1@dont-email.me> <874jm2tbkt.fsf@nosuchdomain.example.com> <u94hip$1cdbp$1@dont-email.me> <87lefeukpy.fsf@bsb.me.uk> <u94pch$1dpd6$1@dont-email.me> <87edl6uf9y.fsf@bsb.me.uk> <u95rn3$1k9hq$1@dont-email.me> <87r0p4tyx4.fsf@bsb.me.uk> <u98g5n$2469a$1@dont-email.me> <u98rs9$26ae9$1@dont-email.me> <u992jq$27kpu$1@dont-email.me> <u99bua$29a16$1@dont-email.me> <87ilafr8e0.fsf@bsb.me.uk> <u99i9b$2ac5l$1@dont-email.me> <u9avim$2l5mt$3@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2c1804d7-256e-4e3a-aa8e-d2cf4cea82can@googlegroups.com>
Subject: Re: you think rust may outthrone c?
From: minfo...@arcor.de (minf...@arcor.de)
Injection-Date: Thu, 20 Jul 2023 12:39:12 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 40
 by: minf...@arcor.de - Thu, 20 Jul 2023 12:39 UTC

David Brown schrieb am Donnerstag, 20. Juli 2023 um 11:43:00 UTC+2:
> On 19/07/2023 22:49, Bart wrote:
> > On 19/07/2023 20:47, Ben Bacarisse wrote:
> >> David Brown <david...@hesbynett.no> writes:
> >>
> >>> On 19/07/2023 18:22, Bart wrote:
> >>>> On 19/07/2023 15:27, David Brown wrote:
> >>>> > On 19/07/2023 13:07, Bart wrote:
> >>>> > For the language definition, it is about what makes sense in the
> >>>> code. C
> >>>> > is a typed language. It does not make it very hard to mess
> >>>> around with
> >>>> > types, and it does not have good support for making your own
> >>>> types that
> >>>> > are convenient to use, but it /is/ a typed language. A float is
> >>>> a float
> >>>> > - it is not an int, and it does not make sense to use it as an int.
> >>>> Isn't that how BCPL (an ancestor of C) worked? You just had chunks of
> >>>> memory and defined what they represented by the operations you chose.
> >>
> >> Yes. a * b multiplies the integer values of two words. a #* b
> >> multiplies the same words but interprets them as floating point. Being
> >> word based, this aspect was very clumsy as you'd need another set of
> >> operators to handle double precision floats.
> >
> > OCaml uses different operators too. * for integer multiply, *. for float.
> That's interesting. Usually stronger typed languages are able to use
> overloading to let you re-use the same operator (though they might not
> let you mix types, such as multiplying an integer and a floating point
> number). I think having different operators for different types would
> quickly get ugly if you want to support lots of types (such as different
> sized integers).

Forth is stack-based. Say you have two items on the integer stack and two items
on the fp-number stack. Overloading '+' doesn't work here because the compiler
wouldn't know on which stack to operate.

Its "queer" syntax is just a matter of getting used to it.

The benefit: Forth is so simple, efficient and compact; you can modify the compiler
as you wish to build your own DSL in just a few kilobytes.

Re: you think rust may outthrone c?

<u9bafs$2n7dq$1@bluemanedhawk.eternal-september.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26365&group=comp.lang.c#26365

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!bluemanedhawk.eternal-september.org!.POSTED!not-for-mail
From: bluemane...@gmail.com (Blue-Maned_Hawk)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 20 Jul 2023 08:49:00 -0400
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <u9bafs$2n7dq$1@bluemanedhawk.eternal-september.org>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u8o2jf$3isv1$1@bluemanedhawk.eternal-september.org>
<u93q47$19p2n$1@dont-email.me>
<u95q1j$1k1sq$1@bluemanedhawk.eternal-september.org>
<u991ot$27egh$2@dont-email.me>
<u99qru$2brfo$1@bluemanedhawk.eternal-september.org>
<u9atgg$2ku7m$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: base64
Injection-Date: Thu, 20 Jul 2023 12:49:00 -0000 (UTC)
Injection-Info: bluemanedhawk.eternal-september.org; posting-host="26941b9b8c4c98b3e5e08fc529aa9a93";
logging-data="2858426"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19GkQxFTW0qllYQOq73fDaRQ19jp7NzvCw="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:wruSV/Mx0dGFvSXxiOlHcvI6DjI=
In-Reply-To: <u9atgg$2ku7m$2@dont-email.me>
Content-Language: en-US
 by: Blue-Maned_Hawk - Thu, 20 Jul 2023 12:49 UTC

On 7/20/23 05:07, Bonita Montero wrote:
> Am 20.07.2023 um 01:16 schrieb Blue-Maned_Hawk:
>> On 7/19/23 12:07, Bonita Montero wrote:
>>> Am 18.07.2023 um 12:37 schrieb Blue-Maned_Hawk:
>>>> On 7/17/23 12:26, Bonita Montero wrote:
>>>>> Am 13.07.2023 um 07:37 schrieb Blue-Maned_Hawk:
>>>>>>
>>>>>> ​Ain't nothing gonna dethrone C until a total revolution of the
>>>>>> modern computing ecosystem; in other words, replacing C would
>>>>>> require replacing everything else all at once.
>>>>>
>>>>> C has already been dethroned many times.
>>>>
>>>> ​I think you and i have different definitions of "dethrone" here.
>>>
>>> This statement is based on the language features. There are now
>>> some languages that are also system-related and also allow almost
>>> optimal performance, but are much more comfortable to program.
>>> F.e. Rust and C++.
>>>
>>
>> ​Languages do not exist in a vacuum; whether or not a language is
>> hypothetically better than C matters not for its practicality in
>> the face of C's pervasiveness.
>
> Rust and C++ can replace C equally well given the
> tools and the languages.
>
​The fact that it's possible doesn't mean that it will happen; again,
languages do not exist in a vaccuum.
--
⚗︎ | /blu.mɛin.dʰak/ | shortens to "Hawk" | he/him/his/himself/Mr.
bluemanedhawk.github.io
Bitches stole my whole ass ␔🭖᷿᪳𝼗᷍⏧𒒫𐻾ࣛ↉�⃣ quoted-printable, can't
have shit in Thunderbird 😩

Re: you think rust may outthrone c?

<u9bas2$2n8dl$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26366&group=comp.lang.c#26366

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 20 Jul 2023 14:55:30 +0200
Organization: A noiseless patient Spider
Lines: 64
Message-ID: <u9bas2$2n8dl$1@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u90c0s$nr2u$1@dont-email.me>
<0ff5dfe1-de32-4dae-872e-5401a3c04c97n@googlegroups.com>
<u90u5r$pnad$1@dont-email.me> <87sf9niqb6.fsf@bsb.me.uk>
<u923gr$tf08$1@dont-email.me> <u92mms$12tmp$1@dont-email.me>
<5fbef78e-14f8-43c4-afaf-17fa5bad12bdn@googlegroups.com>
<b54f60b1-6db7-4ecc-a1f6-b03c78c291een@googlegroups.com>
<u94eb1$1c2vr$1@dont-email.me> <874jm2tbkt.fsf@nosuchdomain.example.com>
<u94hip$1cdbp$1@dont-email.me> <87lefeukpy.fsf@bsb.me.uk>
<u94pch$1dpd6$1@dont-email.me> <87edl6uf9y.fsf@bsb.me.uk>
<u95rn3$1k9hq$1@dont-email.me> <87r0p4tyx4.fsf@bsb.me.uk>
<u98g5n$2469a$1@dont-email.me> <u98rs9$26ae9$1@dont-email.me>
<u992jq$27kpu$1@dont-email.me> <u99bua$29a16$1@dont-email.me>
<87ilafr8e0.fsf@bsb.me.uk> <u99i9b$2ac5l$1@dont-email.me>
<u9avim$2l5mt$3@dont-email.me>
<2c1804d7-256e-4e3a-aa8e-d2cf4cea82can@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 20 Jul 2023 12:55:30 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="fe114861671a8d33dd49743b3e7ee78d";
logging-data="2859445"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/H9PtLX/6oy7Y4Bz1OuhJeTbx/PoBrLps="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:fCnmHtDkkSd4pCRr2yqgTf1VVtY=
In-Reply-To: <2c1804d7-256e-4e3a-aa8e-d2cf4cea82can@googlegroups.com>
Content-Language: en-GB
 by: David Brown - Thu, 20 Jul 2023 12:55 UTC

On 20/07/2023 14:39, minf...@arcor.de wrote:
> David Brown schrieb am Donnerstag, 20. Juli 2023 um 11:43:00 UTC+2:
>> On 19/07/2023 22:49, Bart wrote:
>>> On 19/07/2023 20:47, Ben Bacarisse wrote:
>>>> David Brown <david...@hesbynett.no> writes:
>>>>
>>>>> On 19/07/2023 18:22, Bart wrote:
>>>>>> On 19/07/2023 15:27, David Brown wrote:
>>>>>> > On 19/07/2023 13:07, Bart wrote:
>>>>>> > For the language definition, it is about what makes sense in the
>>>>>> code. C
>>>>>> > is a typed language. It does not make it very hard to mess
>>>>>> around with
>>>>>> > types, and it does not have good support for making your own
>>>>>> types that
>>>>>> > are convenient to use, but it /is/ a typed language. A float is
>>>>>> a float
>>>>>> > - it is not an int, and it does not make sense to use it as an int.
>>>>>> Isn't that how BCPL (an ancestor of C) worked? You just had chunks of
>>>>>> memory and defined what they represented by the operations you chose.
>>>>
>>>> Yes. a * b multiplies the integer values of two words. a #* b
>>>> multiplies the same words but interprets them as floating point. Being
>>>> word based, this aspect was very clumsy as you'd need another set of
>>>> operators to handle double precision floats.
>>>
>>> OCaml uses different operators too. * for integer multiply, *. for float.
>> That's interesting. Usually stronger typed languages are able to use
>> overloading to let you re-use the same operator (though they might not
>> let you mix types, such as multiplying an integer and a floating point
>> number). I think having different operators for different types would
>> quickly get ugly if you want to support lots of types (such as different
>> sized integers).
>
> Forth is stack-based. Say you have two items on the integer stack and two items
> on the fp-number stack. Overloading '+' doesn't work here because the compiler
> wouldn't know on which stack to operate.

Yes, exactly - Forth is basically untyped. OCaml is not stack based -
it is statically typed and makes heavy use of type inference, which
makes it more surprising (to me) that it has different operators for
different types.

>
> Its "queer" syntax is just a matter of getting used to it.
>
> The benefit: Forth is so simple, efficient and compact; you can modify the compiler
> as you wish to build your own DSL in just a few kilobytes.

1 1 + . -> 2 ok
: 1 2 ; -> ok
1 1 + . -> 4 ok

Yes, you can modify Forth as much as you like!

It's a powerful language in its way, but it gives plenty of interesting
ways to make a total mess :-)

Some of the "modern" variants are even more fun. In Color Forth, the
colour of identifiers influences their meaning. And the low-level Forth
used by GreenArray chips makes APL look clear and simple.

Re: you think rust may outthrone c?

<u9berv$2o345$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26367&group=comp.lang.c#26367

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 20 Jul 2023 15:03:44 +0100
Organization: A noiseless patient Spider
Lines: 75
Message-ID: <u9berv$2o345$1@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u90c0s$nr2u$1@dont-email.me>
<0ff5dfe1-de32-4dae-872e-5401a3c04c97n@googlegroups.com>
<u90u5r$pnad$1@dont-email.me> <87sf9niqb6.fsf@bsb.me.uk>
<u923gr$tf08$1@dont-email.me> <u92mms$12tmp$1@dont-email.me>
<5fbef78e-14f8-43c4-afaf-17fa5bad12bdn@googlegroups.com>
<b54f60b1-6db7-4ecc-a1f6-b03c78c291een@googlegroups.com>
<u94eb1$1c2vr$1@dont-email.me> <874jm2tbkt.fsf@nosuchdomain.example.com>
<u94hip$1cdbp$1@dont-email.me> <87lefeukpy.fsf@bsb.me.uk>
<u94pch$1dpd6$1@dont-email.me> <87edl6uf9y.fsf@bsb.me.uk>
<u95rn3$1k9hq$1@dont-email.me> <87r0p4tyx4.fsf@bsb.me.uk>
<u98g5n$2469a$1@dont-email.me> <u98rs9$26ae9$1@dont-email.me>
<u992jq$27kpu$1@dont-email.me> <u99bua$29a16$1@dont-email.me>
<87ilafr8e0.fsf@bsb.me.uk> <u99i9b$2ac5l$1@dont-email.me>
<u9avim$2l5mt$3@dont-email.me>
<2c1804d7-256e-4e3a-aa8e-d2cf4cea82can@googlegroups.com>
<u9bas2$2n8dl$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 20 Jul 2023 14:03:43 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2e13e49741e984015742a684e1703412";
logging-data="2886789"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19e3NUlOOqaaHn0hHsgM/BXvLjMgsFhUoo="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:0s4mhAo/h4a3QMa59jADe+qS2gM=
In-Reply-To: <u9bas2$2n8dl$1@dont-email.me>
 by: Bart - Thu, 20 Jul 2023 14:03 UTC

On 20/07/2023 13:55, David Brown wrote:
> On 20/07/2023 14:39, minf...@arcor.de wrote:

>> Forth is stack-based. Say you have two items on the integer stack and
>> two items
>> on the fp-number stack. Overloading '+' doesn't work here because the
>> compiler
>> wouldn't know on which stack to operate.
>
> Yes, exactly - Forth is basically untyped. OCaml is not stack based -
> it is statically typed and makes heavy use of type inference, which
> makes it more surprising (to me) that it has different operators for
> different types.
>
>>
>> Its "queer" syntax is just a matter of getting used to it.
>>
>> The benefit: Forth is so simple, efficient and compact; you can modify
>> the compiler
>> as you wish to build your own DSL in just a few kilobytes.
>
> 1 1 + . -> 2 ok
> : 1 2 ; -> ok
> 1 1 + . -> 4 ok
>
> Yes, you can modify Forth as much as you like!
>
> It's a powerful language in its way, but it gives plenty of interesting
> ways to make a total mess :-)
>
> Some of the "modern" variants are even more fun. In Color Forth, the
> colour of identifiers influences their meaning. And the low-level Forth
> used by GreenArray chips makes APL look clear and simple.

I've tried to get into Forth a few times but found it impossible. I just
can't get a grip on the language.

I even tried my own toy implementation, then when looking for examples
to download, found that every one used its own slightly different
dialect. It's a language you make up as you go. However simple stuff
like this works:

Bart-Forth
Type bye, quit or exit to stop
> 2 2 + .
4
>

As for its being small, I download GForth for Windows, it was about a
100KB executable. Not huge, but I have my own stack-based IL language
interpreter which is only 80KB (including a 30KB stdlib which could be
reduced).

But it's a real, full-spec language with support for i64, u64, f64, f32,
storage types of 8/16/32 bits, full pointer arithmetic, floating point
support /using the same stack/, has an FFI to call into external
routines including C etc.

(It can run most of my M-language programs, but interpreted, including
itself.)

It is intended for machine generation so it is not pretty, but it is
still easier for me to write code, if I had to do it manually, than in
Forth. Although of course a proper HLL is always superior.

My above example, usually submitted by file not REPL, would be:

loadimm 2
loadimm 2
add i64 # operators need type annotations
printi64

(Forth as a target language for a compiler has been proposed; I think it
makes a lousy target compared with my IL.)

Re: you think rust may outthrone c?

<u9bg5f$2o9ci$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26368&group=comp.lang.c#26368

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 20 Jul 2023 16:25:52 +0200
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <u9bg5f$2o9ci$1@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u8o2jf$3isv1$1@bluemanedhawk.eternal-september.org>
<u93q47$19p2n$1@dont-email.me>
<u95q1j$1k1sq$1@bluemanedhawk.eternal-september.org>
<u991ot$27egh$2@dont-email.me>
<u99qru$2brfo$1@bluemanedhawk.eternal-september.org>
<u9atgg$2ku7m$2@dont-email.me>
<u9bafs$2n7dq$1@bluemanedhawk.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 20 Jul 2023 14:25:51 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="10031f0e81423a2c0e359bd216cbd3a1";
logging-data="2893202"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/b08QDTWZVCp39k0yj5BF3iI4EqYiLUqI="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:l4LjISoKPxJN4pZqGbuoIFQp9qA=
Content-Language: de-DE
In-Reply-To: <u9bafs$2n7dq$1@bluemanedhawk.eternal-september.org>
 by: Bonita Montero - Thu, 20 Jul 2023 14:25 UTC

Am 20.07.2023 um 14:49 schrieb Blue-Maned_Hawk:
> On 7/20/23 05:07, Bonita Montero wrote:
>> Am 20.07.2023 um 01:16 schrieb Blue-Maned_Hawk:
>>> On 7/19/23 12:07, Bonita Montero wrote:
>>>> Am 18.07.2023 um 12:37 schrieb Blue-Maned_Hawk:
>>>>> On 7/17/23 12:26, Bonita Montero wrote:
>>>>>> Am 13.07.2023 um 07:37 schrieb Blue-Maned_Hawk:
>>>>>>>
>>>>>>> ​Ain't nothing gonna dethrone C until a total revolution of the
>>>>>>> modern computing ecosystem; in other words, replacing C would
>>>>>>> require replacing everything else all at once.
>>>>>>
>>>>>> C has already been dethroned many times.
>>>>>
>>>>> ​I think you and i have different definitions of "dethrone" here.
>>>>
>>>> This statement is based on the language features. There are now
>>>> some languages that are also system-related and also allow almost
>>>> optimal performance, but are much more comfortable to program.
>>>> F.e. Rust and C++.
>>>>
>>>
>>> ​Languages do not exist in a vacuum; whether or not a language is
>>> hypothetically better than C matters not for its practicality in
>>> the face of C's pervasiveness.
>>
>> Rust and C++ can replace C equally well given the
>> tools and the languages.
>>
>
> ​The fact that it's possible doesn't mean that it will happen; again,
> languages do not exist in a vaccuum.

C is chosen many times when C or C++ would be a viable option
and both would save much work.

Re: you think rust may outthrone c?

<u9bmvs$2pmgm$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26372&group=comp.lang.c#26372

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 20 Jul 2023 18:22:19 +0200
Organization: A noiseless patient Spider
Lines: 125
Message-ID: <u9bmvs$2pmgm$1@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u90c0s$nr2u$1@dont-email.me>
<0ff5dfe1-de32-4dae-872e-5401a3c04c97n@googlegroups.com>
<u90u5r$pnad$1@dont-email.me> <87sf9niqb6.fsf@bsb.me.uk>
<u923gr$tf08$1@dont-email.me> <u92mms$12tmp$1@dont-email.me>
<5fbef78e-14f8-43c4-afaf-17fa5bad12bdn@googlegroups.com>
<b54f60b1-6db7-4ecc-a1f6-b03c78c291een@googlegroups.com>
<u94eb1$1c2vr$1@dont-email.me> <874jm2tbkt.fsf@nosuchdomain.example.com>
<u94hip$1cdbp$1@dont-email.me> <87lefeukpy.fsf@bsb.me.uk>
<u94pch$1dpd6$1@dont-email.me> <87edl6uf9y.fsf@bsb.me.uk>
<u95rn3$1k9hq$1@dont-email.me> <87r0p4tyx4.fsf@bsb.me.uk>
<u98g5n$2469a$1@dont-email.me> <u98rs9$26ae9$1@dont-email.me>
<u992jq$27kpu$1@dont-email.me> <u99bua$29a16$1@dont-email.me>
<87ilafr8e0.fsf@bsb.me.uk> <u99i9b$2ac5l$1@dont-email.me>
<u9avim$2l5mt$3@dont-email.me>
<2c1804d7-256e-4e3a-aa8e-d2cf4cea82can@googlegroups.com>
<u9bas2$2n8dl$1@dont-email.me> <u9berv$2o345$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 20 Jul 2023 16:22:20 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="fe114861671a8d33dd49743b3e7ee78d";
logging-data="2939414"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1//p2Vz48I2rDXcCZ9ysjh4Bt+yDcB6DRA="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:r25O5WeTpo5ebUWl5BKWBkOZTew=
In-Reply-To: <u9berv$2o345$1@dont-email.me>
Content-Language: en-GB
 by: David Brown - Thu, 20 Jul 2023 16:22 UTC

On 20/07/2023 16:03, Bart wrote:
>
> On 20/07/2023 13:55, David Brown wrote:
> > On 20/07/2023 14:39, minf...@arcor.de wrote:
>
> >> Forth is stack-based. Say you have two items on the integer stack and
> >> two items
> >> on the fp-number stack. Overloading '+' doesn't work here because the
> >> compiler
> >> wouldn't know on which stack to operate.
> >
> > Yes, exactly - Forth is basically untyped.  OCaml is not stack based -
> > it is statically typed and makes heavy use of type inference, which
> > makes it more surprising (to me) that it has different operators for
> > different types.
> >
> >>
> >> Its "queer" syntax is just a matter of getting used to it.
> >>
> >> The benefit: Forth is so simple, efficient and compact; you can modify
> >> the compiler
> >> as you wish to build your own DSL in just a few kilobytes.
> >
> > 1 1 + .     -> 2 ok
> > : 1 2 ;     -> ok
> > 1 1 + .     -> 4 ok
> >
> > Yes, you can modify Forth as much as you like!
> >
> > It's a powerful language in its way, but it gives plenty of interesting
> > ways to make a total mess :-)
> >
> > Some of the "modern" variants are even more fun.  In Color Forth, the
> > colour of identifiers influences their meaning.  And the low-level Forth
> > used by GreenArray chips makes APL look clear and simple.
>
> I've tried to get into Forth a few times but found it impossible. I just
> can't get a grip on the language.
>

Like Yoda must you think if Forth to understand you are. Or something
like that!

While the stack notation lets you write simple things easily enough, it
gets ugly fast when you want to access data that is not on the stack.

I haven't done more than play around a little with it myself. But I
know some people who swear it's the best thing since sliced bread. I
guess it just takes time to get used to it.

> I even tried my own toy implementation, then when looking for examples
> to download, found that every one used its own slightly different
> dialect. It's a language you make up as you go. However simple stuff
> like this works:
>
>     Bart-Forth
>     Type bye, quit or exit to stop
>     > 2 2 + .
>     4
>     >
>

Yes, that's a big selling point of Forth - it is easy to make an
interpreter in it. And you can extend it in many ways - it's common to
have an assembler (with an RPN notation, naturally) in it.

I have also seen hardware description languages implemented in Forth. I
read of a system that used that to implement a CPU in an FPGA, and since
the software was all in Forth, you could basically pick which words (the
Forth term for functions) were hardware opcodes, and which were in
software. The design was extremely flexible about the balance between
size in the FPGA, and speed of the device.

> As for its being small, I download GForth for Windows, it was about a
> 100KB executable. Not huge, but I have my own stack-based IL language
> interpreter which is only 80KB (including a 30KB stdlib which could be
> reduced).

Well, remember that GForth includes an optimising compiler, not just an
interpreter. And it supports a /lot/ beyond basic Forth.

(You might get on with the maintainer of GForth. He is a rabid
gcc-hater who thinks compiler optimisations that take advantage of UB
are the biggest curse to face mankind. He is also extremely smart, and
GForth has all kinds of ugly tricks for speed.)

>
> But it's a real, full-spec language with support for i64, u64, f64, f32,
> storage types of 8/16/32 bits, full pointer arithmetic, floating point
> support /using the same stack/, has an FFI to call into external
> routines including C etc.
>
> (It can run most of my M-language programs, but interpreted, including
> itself.)
>
> It is intended for machine generation so it is not pretty, but it is
> still easier for me to write code, if I had to do it manually, than in
> Forth. Although of course a proper HLL is always superior.
>
> My above example, usually submitted by file not REPL, would be:
>
>     loadimm 2
>     loadimm 2
>     add i64             # operators need type annotations
>     printi64
>
> (Forth as a target language for a compiler has been proposed; I think it
> makes a lousy target compared with my IL.)

Forth as a target language has its advantages and disadvantages.

Many small processor designs - indeed, almost all 4-bit devices - use a
Forth-inspired instruction set. With small instructions you have no
room for coding register numbers - stack-based addressing is much
simpler. And when developing for them, your program simply builds up
words on top of the assembly code - it's more appropriate for these
things than C coding would be!

Forth was also used for a while for device drivers in hardware, with the
idea that hardware cards could have their driver code in Forth in a
little eeprom, and the host computer could run it regardless of the
processor. It did not really take off, however.

Re: you think rust may outthrone c?

<20230720085729.566@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26374&group=comp.lang.c#26374

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 20 Jul 2023 16:44:15 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 187
Message-ID: <20230720085729.566@kylheku.com>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<87sf9niqb6.fsf@bsb.me.uk> <u923gr$tf08$1@dont-email.me>
<u92mms$12tmp$1@dont-email.me>
<5fbef78e-14f8-43c4-afaf-17fa5bad12bdn@googlegroups.com>
<b54f60b1-6db7-4ecc-a1f6-b03c78c291een@googlegroups.com>
<u94eb1$1c2vr$1@dont-email.me> <874jm2tbkt.fsf@nosuchdomain.example.com>
<u94hip$1cdbp$1@dont-email.me> <87lefeukpy.fsf@bsb.me.uk>
<u94pch$1dpd6$1@dont-email.me> <87edl6uf9y.fsf@bsb.me.uk>
<u95rn3$1k9hq$1@dont-email.me> <87r0p4tyx4.fsf@bsb.me.uk>
<u98g5n$2469a$1@dont-email.me> <u98rs9$26ae9$1@dont-email.me>
<87mszrsx6z.fsf@bsb.me.uk> <u99alq$292ke$1@dont-email.me>
<87wmyvr9kg.fsf@bsb.me.uk> <87fs5jseuv.fsf@nosuchdomain.example.com>
<20230719160546.668@kylheku.com> <87bkg7s5zt.fsf@nosuchdomain.example.com>
<u9aunu$2l5mt$1@dont-email.me>
Injection-Date: Thu, 20 Jul 2023 16:44:15 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2ea12c6fbeb32cb78a2f4233d4a3c14b";
logging-data="2946899"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/7hoqGP69QTcROpa4Q+ZkbxW4UobpQEkQ="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:/h+/OkDGvYwUaMy3v98au4kvZGw=
 by: Kaz Kylheku - Thu, 20 Jul 2023 16:44 UTC

On 2023-07-20, David Brown <david.brown@hesbynett.no> wrote:
> On 20/07/2023 03:53, Keith Thompson wrote:
>> Kaz Kylheku <864-117-4973@kylheku.com> writes:
>>> On 2023-07-19, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>>>> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>>>> [...]
>>>>> 6.2.6.1 p5 says (in part)
>>>>>
>>>>> "Certain object representations need not represent a value of the
>>>>> object type. If such a representation is read by an lvalue expression
>>>>> that does not have character type, the behavior is undefined."
>>>>
>>>> Yes, but that's not why reading an uninitialized int object has
>>>> undefined behavior.
>>>>
>>>> If we know that, for example, CHAR_BIT==8, sizeof(int)==4,
>>>> INT_MAX==2147483647, and INT_MIN==-INT_MAX-1, then we can rigorously
>>>> infer that int has no padding bits, and no trap representations.
>>>>
>>>>> Elsewhere we can find wording to say that uninitialised local variables
>>>>> and newly allocated storage contain indeterminate representations. This
>>>>> includes the possibility of non-value representations.
>>>>
>>>> Yes, but even if the memory happens to contain a valid representation
>>>> for type int, the representation is still indeterminate. Indeterminacy
>>>> is not defined by the bits making up the representation.
>>>>
>>>> An indeterminate value is by definition "either an unspecified value or
>>>> a trap representation". Annex J lists "The value of an object with
>>>> automatic storage duration is used while it is indeterminate" as an
>>>> example of undefined behavior.
>>>
>>> Ah, but we can produce an unspecified value without accessing
>>> an uninitialized object!
>>>
>>> Order of evaluation is unspecified, thus:
>>>
>>> int global = 1;
>>>
>>> int operand(void) { return ++global; }
>>>
>>> // ...
>>>
>>> {
>>> int val = operand() * operand() + operand();
>>>
>>> }
>>>
>>>
>>> Here, val could be
>>>
>>> 2 * 3 + 4 = 10
>>> 2 * 4 + 3 = 11
>>> 3 * 2 + 4 = 10
>>> 3 * 4 + 2 = 14
>>> 4 * 3 + 2 = 14
>>> 4 * 2 + 3 = 11
>>>
>>> So val has an unspecified value which could be 10, 11 or 14.
>>>
>>> Since an unspecified value is indeterminate, does it mean that
>>> using val is undefined behavior?
>>>
>>> No; the reason that using an unspecified value is undefined behavior
>>> is that on some implementations, an unspecified value could be
>>> a trap representation.
>>>
>>> If we know that the implementation has no trap representation
>>> in the type int, then an uninitialized value is in the same
>>> category as val above: it's an unspecified value. Behavior
>>> which depends on it is unspecified behavior.
>>
>> That makes sense.
>>
>> The problem is that (referring to N1570, and I don't see any relevant
>> changes in the latest public C23 draft, N3096), Annex J says gives
>>
>> The value of an object with automatic storage duration is used
>> while it is indeterminate (6.2.4, 6.7.9, 6.8).
>>
>> as an example of undefined behavior.
>>
>> If that is accurate, then this program:
>>
>> #include <limits.h>
>> int main(void) {
>> int foo;
>> if (sizeof (int) == 4 &&
>> CHAR_BIT == 8 &&
>> INT_MAX == 2147483647 &&
>> INT_MIN == -INT_MAX-1)
>> {
>> int bar = foo;
>> }
>> }
>>
>> has undefined behavior on an implementation where the condition is true.
>> (Of course that UB is likely to manifest as quietly doing nothing.)
>>
>> Annex J is non-normative, and depends on normative statements
>> elsewhere in the standard. Following the section numbers given in
>> Annex J and searching for occurrences of "indeterminate value",
>> I have so far been unable to confirm that the statement in Annex
>> J is correct.
>>
>> Either Annex J is incorrect, or accessing an uninitalized
>> automatic object is UB even if the object cannot possibly hold a
>> trap representation. (I'd be satisfied either way; I'd like the
>> standard to be internally consistent.)
>>
>> Perhaps someone else can find something in the standard that I've
>> missed.
>>
>
> I can add something, but I don't know if you missed it - and it is not
> at all conclusive.
>
>
> 6.7.9p10 says:
>
> """
> If an object that has automatic storage duration is not initialized
> explicitly, its value is indeterminate.
> """

Here we can "macro expand" the definition of indeterminate;
this means exactly the same thing as "it has either an unspecified
value, or else a trap representation".

If the implementation doesn't have the latter, it has to be the former.

An unspecified value is very similar to unspecified behavior:

"[A] valid value of the relevant type where this International Standard
imposes no requirements on which value is chosen in any instance."

Note the word "valid"!

If the program subsequently makes a decision based on the value,
the behavior cannot be anything but unspecified.

This is not just automatic storage variables.

"The malloc function allocates space for an object whose size is
specified by size and whose value is indeterminate"

We can allocate space for a struct type with malloc.
When we assign values to the members, the padding bits in the
structure remain uninitialized.

Yet, we can copy a structure using memcpy, even if it has
indeterminate padding bits.

This is because the underlying model is that the structure is accessed
as an array of unsigned char, and that type has no trap representations.
Therefore, the memcpy is reliably making a replica of the unspecified
values; the copied structure faithfully replicates the padding bits of
the original, that don't contribute to the value of its members.

I think that it is a defective wording to say that the use of an
indeterminate value is undefined behavior, because only in the situation
in which we don't know anything about the characteristics of the
implementation do we not know whether the behavior will be defined and
so have to conclude that we don't know the definition of behavior.

But we always know the characteristics of the implementation on which we
are running a program, and whether or not a given type has trap
representations.

Implementation, as an aggregate, do not have behavior. All
implementations exhibit behavior individually.
There are obvious ways in which a program can have undefined behavvior
on one implementation, but not another:

We don't assert that "1U << 31" has undefined behavior, only that it has
undefined behavior if unsigned int doesn't have at least 32 value bits.
There is no behavior without an implementation, and there is no
implementation without characteristics being pinned down.

Individual language constructs have behavior, but always in
consideration of being inside an implementation, where we take into
account all characteristics that are relevant to that construct.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: you think rust may outthrone c?

<u9bs1u$2qj43$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26375&group=comp.lang.c#26375

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 20 Jul 2023 19:48:49 +0200
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <u9bs1u$2qj43$1@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u8o2jf$3isv1$1@bluemanedhawk.eternal-september.org>
<u93q47$19p2n$1@dont-email.me>
<u95q1j$1k1sq$1@bluemanedhawk.eternal-september.org>
<u991ot$27egh$2@dont-email.me>
<u99qru$2brfo$1@bluemanedhawk.eternal-september.org>
<u9atgg$2ku7m$2@dont-email.me>
<u9bafs$2n7dq$1@bluemanedhawk.eternal-september.org>
<u9bg5f$2o9ci$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 20 Jul 2023 17:48:46 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="10031f0e81423a2c0e359bd216cbd3a1";
logging-data="2968707"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+L5mTstaSx8zj6ZSu+ugfZE8KbF5p3ySQ="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:qnDlH6K67gPQPBRmjwMLr1D1doI=
Content-Language: de-DE
In-Reply-To: <u9bg5f$2o9ci$1@dont-email.me>
 by: Bonita Montero - Thu, 20 Jul 2023 17:48 UTC

Am 20.07.2023 um 16:25 schrieb Bonita Montero:
> Am 20.07.2023 um 14:49 schrieb Blue-Maned_Hawk:
>> On 7/20/23 05:07, Bonita Montero wrote:
>>> Am 20.07.2023 um 01:16 schrieb Blue-Maned_Hawk:
>>>> On 7/19/23 12:07, Bonita Montero wrote:
>>>>> Am 18.07.2023 um 12:37 schrieb Blue-Maned_Hawk:
>>>>>> On 7/17/23 12:26, Bonita Montero wrote:
>>>>>>> Am 13.07.2023 um 07:37 schrieb Blue-Maned_Hawk:
>>>>>>>>
>>>>>>>> ​Ain't nothing gonna dethrone C until a total revolution of the
>>>>>>>> modern computing ecosystem; in other words, replacing C would
>>>>>>>> require replacing everything else all at once.
>>>>>>>
>>>>>>> C has already been dethroned many times.
>>>>>>
>>>>>> ​I think you and i have different definitions of "dethrone" here.
>>>>>
>>>>> This statement is based on the language features. There are now
>>>>> some languages that are also system-related and also allow almost
>>>>> optimal performance, but are much more comfortable to program.
>>>>> F.e. Rust and C++.
>>>>>
>>>>
>>>> ​Languages do not exist in a vacuum; whether or not a language is
>>>> hypothetically better than C matters not for its practicality in
>>>> the face of C's pervasiveness.
>>>
>>> Rust and C++ can replace C equally well given the
>>> tools and the languages.
>>>
>>
>> ​The fact that it's possible doesn't mean that it will happen; again,
>> languages do not exist in a vaccuum.
>
> C is chosen many times when C or C++ would be a viable option
^ Rust
> and both would save much work.
>
>

Re: you think rust may outthrone c?

<u9bv2c$2r3ek$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26376&group=comp.lang.c#26376

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: nos...@please.ty (jak)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 20 Jul 2023 20:40:09 +0200
Organization: A noiseless patient Spider
Lines: 66
Message-ID: <u9bv2c$2r3ek$1@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u8p0kv$h9r$1@matrix.hispagatos.org> <20230713104558.553@kylheku.com>
<u8phd0$3niul$1@dont-email.me> <UpYrM.257503$W7d4.2562@fx18.iad>
<u8pmt9$3o80g$1@dont-email.me> <u8q0q4$3p89v$1@dont-email.me>
<u8qqpv$3v3pg$1@dont-email.me> <u8r94r$dn9$1@dont-email.me>
<u8rcu9$qd2$1@dont-email.me> <u8rdrf$uca$1@dont-email.me>
<20230714140153.112@kylheku.com> <u8sf33$4nc3$1@dont-email.me>
<u8u3ge$cscl$1@dont-email.me> <87sf9oye05.fsf@nosuchdomain.example.com>
<a189a8ff-5e91-43b7-9601-1f29b6a667bfn@googlegroups.com>
<u90c0s$nr2u$1@dont-email.me>
<0ff5dfe1-de32-4dae-872e-5401a3c04c97n@googlegroups.com>
<u90u5r$pnad$1@dont-email.me> <87sf9niqb6.fsf@bsb.me.uk>
<u923gr$tf08$1@dont-email.me> <87mszvwbwl.fsf@bsb.me.uk>
<ea263e0e-b936-43d2-a4b2-9fe62ccccce9n@googlegroups.com>
<u93dlc$158qe$1@dont-email.me> <20230717113353.356@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 20 Jul 2023 18:40:12 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="28e50f7c17c8863d1d047074630c4c2d";
logging-data="2985428"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18CILJxzlj0nZ9Y/uIQ32x1"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.16
Cancel-Lock: sha1:U75KACMymaXPBCTgIu4BJJlQghE=
In-Reply-To: <20230717113353.356@kylheku.com>
 by: jak - Thu, 20 Jul 2023 18:40 UTC

Kaz Kylheku ha scritto:
> On 2023-07-17, David Brown <david.brown@hesbynett.no> wrote:
>> On 17/07/2023 12:16, Malcolm McLean wrote:
>>> On Monday, 17 July 2023 at 02:43:50 UTC+1, Ben Bacarisse wrote:
>>> messy (if you've several similar functions, do you create the same union everywhere
>>> in local scope, as you did, or do you create one in global scope - neither answer
>>> is ideal).
>>
>> Your code is messy too. It's okay for something as rarely needed as
>> this to be a bit verbose.
>
> But does it have to be verbose? Maybe we could use macros to shorten it.
>
> We had this bit of code upthread:
>
> inline bool sign_bit(float f)
> {
> union {
> uint32_t u;
> float f;
> } u;
> u.f = f;
> return u.u & 0x80000000;
> }
>
>
> The kernel here is that a union is declared with two members, of
> different types. It is initialized with one, and accessed with the other.
>
> With C99 syntax, we can do that as one expression:
>
> #include <stdio.h>
>
> #define union_cast(to_type, from_type, value) \
> ((union { to_type to; from_type from; }){ .from = (value) }.to)
>

Around the web I found this macro similar to yours:

#define chk_sign(from_type, value) \
(!!(union { from_type from; \
struct { \
uint64_t rest : ((sizeof(from_type) * CHAR_BIT) -
1); \
uint64_t sign : 1; \
} to; \
}) { .from = (value) }.to.sign)

>
> int main(void)
> {
> float x = 4.2;
> unsigned y = union_cast(unsigned, float, x);
> printf("%x\n", y);
> return 0;
> }
>
> Output produced:
>
> 40866666
>
> We could have a static assertion in there that to_type and from_type
> are of the same size and whatnot.
>

Re: you think rust may outthrone c?

<20230720121839.520@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26378&group=comp.lang.c#26378

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 20 Jul 2023 19:27:14 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 72
Message-ID: <20230720121839.520@kylheku.com>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u8p0kv$h9r$1@matrix.hispagatos.org> <20230713104558.553@kylheku.com>
<u8phd0$3niul$1@dont-email.me> <UpYrM.257503$W7d4.2562@fx18.iad>
<u8pmt9$3o80g$1@dont-email.me> <u8q0q4$3p89v$1@dont-email.me>
<u8qqpv$3v3pg$1@dont-email.me> <u8r94r$dn9$1@dont-email.me>
<u8rcu9$qd2$1@dont-email.me> <u8rdrf$uca$1@dont-email.me>
<20230714140153.112@kylheku.com> <u8sf33$4nc3$1@dont-email.me>
<u8u3ge$cscl$1@dont-email.me> <87sf9oye05.fsf@nosuchdomain.example.com>
<a189a8ff-5e91-43b7-9601-1f29b6a667bfn@googlegroups.com>
<u90c0s$nr2u$1@dont-email.me>
<0ff5dfe1-de32-4dae-872e-5401a3c04c97n@googlegroups.com>
<u90u5r$pnad$1@dont-email.me> <87sf9niqb6.fsf@bsb.me.uk>
<u923gr$tf08$1@dont-email.me> <87mszvwbwl.fsf@bsb.me.uk>
<ea263e0e-b936-43d2-a4b2-9fe62ccccce9n@googlegroups.com>
<u93dlc$158qe$1@dont-email.me> <20230717113353.356@kylheku.com>
<u9bv2c$2r3ek$1@dont-email.me>
Injection-Date: Thu, 20 Jul 2023 19:27:14 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2ea12c6fbeb32cb78a2f4233d4a3c14b";
logging-data="2996884"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+HqfVSM1zZV9Ft/oGiMFrBOK7GB28vxDs="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:oRv0RoeYhvp6eGhiXT9ocSZnCaE=
 by: Kaz Kylheku - Thu, 20 Jul 2023 19:27 UTC

On 2023-07-20, jak <nospam@please.ty> wrote:
> Kaz Kylheku ha scritto:
>> With C99 syntax, we can do that as one expression:
>>
>> #include <stdio.h>
>>
>> #define union_cast(to_type, from_type, value) \
>> ((union { to_type to; from_type from; }){ .from = (value) }.to)
>>
>
> Around the web I found this macro similar to yours:
>
> #define chk_sign(from_type, value) \
> (!!(union { from_type from; \
> struct { \
> uint64_t rest : ((sizeof(from_type) * CHAR_BIT) -
> 1); \
> uint64_t sign : 1; \
> } to; \
> }) { .from = (value) }.to.sign)

That alone not work on anything but big endian machines.

Look at that file again to see whether it has something like

#if BIG_ENDIAN
#define chk_sign ... // the above definition
#else
#define chk_sign ... // alternative with rearranged union
#endif

A common allocation strategy for bitfields is that they follow
endianness. When a 1-bit field is allocated into a brand new
bitfield packing cell (which could be int-sized or whatever),
it goes into the lowest-offset byte first.

Within a byte, the order goes from MSB to LSB on big endian,
and LSB to msb on little endian:

Thus, here if we put 0x80 into x:

union {
unsigned char x;
unsigned y : 1;
};

then y will be 1 on big endian, 0 on little.

We cannot necessarily deduce all this from the ISO C standard, but
that's the way it is with GCC.

In device drivers it's not uncommon to see this:

struct foo_registers {
// 32 bit status word
#if BIG_ENDIAN
unsigned int on_fire : 1;
unsigned int read_ready : 1;
unsigned int locked_up : 1;
/// ... 29 more
#else
/// ... 29 more
unsigned int locked_up : 1;
unsigned int read_ready : 1;
unsigned int on_fire : 1;
#endif
}

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: you think rust may outthrone c?

<87y1japdjc.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26380&group=comp.lang.c#26380

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 20 Jul 2023 20:51:19 +0100
Organization: A noiseless patient Spider
Lines: 56
Message-ID: <87y1japdjc.fsf@bsb.me.uk>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<87sf9niqb6.fsf@bsb.me.uk> <u923gr$tf08$1@dont-email.me>
<u92mms$12tmp$1@dont-email.me>
<5fbef78e-14f8-43c4-afaf-17fa5bad12bdn@googlegroups.com>
<b54f60b1-6db7-4ecc-a1f6-b03c78c291een@googlegroups.com>
<u94eb1$1c2vr$1@dont-email.me>
<874jm2tbkt.fsf@nosuchdomain.example.com>
<u94hip$1cdbp$1@dont-email.me> <87lefeukpy.fsf@bsb.me.uk>
<u94pch$1dpd6$1@dont-email.me> <87edl6uf9y.fsf@bsb.me.uk>
<u95rn3$1k9hq$1@dont-email.me> <87r0p4tyx4.fsf@bsb.me.uk>
<u98g5n$2469a$1@dont-email.me> <u98rs9$26ae9$1@dont-email.me>
<u992jq$27kpu$1@dont-email.me> <u99bua$29a16$1@dont-email.me>
<87ilafr8e0.fsf@bsb.me.uk> <u99i9b$2ac5l$1@dont-email.me>
<u9avim$2l5mt$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="718a5a877a69dbd1318115baaef9d27f";
logging-data="3004857"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+zEZzWouYQqMBhvBelF4wazd4p8G17CdY="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:NYA4pkDEvce8dB4vFs3UOB1GSvM=
sha1:GfFy7bllojEZyUA27bfq0lQoMns=
X-BSB-Auth: 1.743758c8c2a472ca5e42.20230720205119BST.87y1japdjc.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 20 Jul 2023 19:51 UTC

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

> On 19/07/2023 22:49, Bart wrote:
>> On 19/07/2023 20:47, Ben Bacarisse wrote:
>>> David Brown <david.brown@hesbynett.no> writes:
>>>
>>>> On 19/07/2023 18:22, Bart wrote:
>>>>> On 19/07/2023 15:27, David Brown wrote:
>>>>>   > On 19/07/2023 13:07, Bart wrote:
>>>>>   > For the language definition, it is about what makes sense in the
>>>>> code. C
>>>>>   > is a typed language.  It does not make it very hard to mess around
>>>>> with
>>>>>   > types, and it does not have good support for making your own types
>>>>> that
>>>>>   > are convenient to use, but it /is/ a typed language.  A float is a
>>>>> float
>>>>>   > - it is not an int, and it does not make sense to use it as an int.
>>>>> Isn't that how BCPL (an ancestor of C) worked? You just had chunks of
>>>>> memory and defined what they represented by the operations you chose.
>>>
>>> Yes.  a * b multiplies the integer values of two words.  a #* b
>>> multiplies the same words but interprets them as floating point.  Being
>>> word based, this aspect was very clumsy as you'd need another set of
>>> operators to handle double precision floats.
>> OCaml uses different operators too. * for integer multiply, *. for float.
>
> That's interesting. Usually stronger typed languages are able to use
> overloading to let you re-use the same operator (though they might not let
> you mix types, such as multiplying an integer and a floating point number).
> I think having different operators for different types would quickly get
> ugly if you want to support lots of types (such as different sized
> integers).

ML (the language that OCaml is based on) uses the same operators for all
arithmetic, so mixed type arithmetic can become complicated. Haskell
has the same issue. It's what flummoxes most beginners in the first few
days. Since both Haskell and ML have strong type inference, they look,
to the uninitiated, like scripting languages with run-time determined
types, so it's baffling (at first) when one needs all those fromIntegral
calls.

I don't know for sure, but I'd bet that is why OCaml went with distinct
operators.

> OCaml has been on my list of languages to learn for many years, but has not
> got near the top yet!
>
>> I think that is to help with its type inference.

It certainly does that. I'm just not 100% sure that that was why the
decision was made.

--
Ben.

Re: you think rust may outthrone c?

<u9c3ur$2rpbs$4@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26385&group=comp.lang.c#26385

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 20 Jul 2023 13:03:38 -0700
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <u9c3ur$2rpbs$4@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u90c0s$nr2u$1@dont-email.me>
<0ff5dfe1-de32-4dae-872e-5401a3c04c97n@googlegroups.com>
<u90u5r$pnad$1@dont-email.me> <87sf9niqb6.fsf@bsb.me.uk>
<u923gr$tf08$1@dont-email.me> <u92mms$12tmp$1@dont-email.me>
<5fbef78e-14f8-43c4-afaf-17fa5bad12bdn@googlegroups.com>
<b54f60b1-6db7-4ecc-a1f6-b03c78c291een@googlegroups.com>
<u94eb1$1c2vr$1@dont-email.me> <874jm2tbkt.fsf@nosuchdomain.example.com>
<u94hip$1cdbp$1@dont-email.me> <87lefeukpy.fsf@bsb.me.uk>
<u94pch$1dpd6$1@dont-email.me> <87edl6uf9y.fsf@bsb.me.uk>
<u95rn3$1k9hq$1@dont-email.me> <87r0p4tyx4.fsf@bsb.me.uk>
<u98g5n$2469a$1@dont-email.me> <u98rs9$26ae9$1@dont-email.me>
<u992jq$27kpu$1@dont-email.me> <u99bua$29a16$1@dont-email.me>
<87ilafr8e0.fsf@bsb.me.uk> <u9aval$2l5mt$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 20 Jul 2023 20:03:40 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="548cb02f8621473374aa0fef010fdab5";
logging-data="3007868"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ShLlcYNeIfAoNmRXoG7Zm9cqgjSvBN+c="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:iwqDA3VtHNJP/QKdSIqlOmFPxRM=
Content-Language: en-US
In-Reply-To: <u9aval$2l5mt$2@dont-email.me>
 by: Chris M. Thomasson - Thu, 20 Jul 2023 20:03 UTC

On 7/20/2023 2:38 AM, David Brown wrote:
> On 19/07/2023 21:47, Ben Bacarisse wrote:
>> David Brown <david.brown@hesbynett.no> writes:
[...]
> In 1982 I was 10 years old.  I was familiar with BASIC on at least two
> different machines, but I didn't look at other languages for another
> couple of years.  BCPL passed me by, as did Fortran and Algol.
[...]

Fwiw, In 1982 I was 5 years old and working with BASIC, LOGO and PILOT
on my trusty Atari.

Re: you think rust may outthrone c?

<u9c40h$2rpbs$5@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26386&group=comp.lang.c#26386

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 20 Jul 2023 13:04:32 -0700
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <u9c40h$2rpbs$5@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u90c0s$nr2u$1@dont-email.me>
<0ff5dfe1-de32-4dae-872e-5401a3c04c97n@googlegroups.com>
<u90u5r$pnad$1@dont-email.me> <87sf9niqb6.fsf@bsb.me.uk>
<u923gr$tf08$1@dont-email.me> <u92mms$12tmp$1@dont-email.me>
<5fbef78e-14f8-43c4-afaf-17fa5bad12bdn@googlegroups.com>
<b54f60b1-6db7-4ecc-a1f6-b03c78c291een@googlegroups.com>
<u94eb1$1c2vr$1@dont-email.me> <874jm2tbkt.fsf@nosuchdomain.example.com>
<u94hip$1cdbp$1@dont-email.me> <87lefeukpy.fsf@bsb.me.uk>
<u94pch$1dpd6$1@dont-email.me> <87edl6uf9y.fsf@bsb.me.uk>
<u95rn3$1k9hq$1@dont-email.me> <87r0p4tyx4.fsf@bsb.me.uk>
<u98g5n$2469a$1@dont-email.me> <u98rs9$26ae9$1@dont-email.me>
<u992jq$27kpu$1@dont-email.me> <u99bua$29a16$1@dont-email.me>
<87ilafr8e0.fsf@bsb.me.uk> <u99i9b$2ac5l$1@dont-email.me>
<u9avim$2l5mt$3@dont-email.me>
<2c1804d7-256e-4e3a-aa8e-d2cf4cea82can@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 20 Jul 2023 20:04:33 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="548cb02f8621473374aa0fef010fdab5";
logging-data="3007868"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/x0a0q/gjS4XIob/sGXrLj4DVM/sho1zg="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:eYSvLjnCYFCtcJWnG8trsDsdiDc=
Content-Language: en-US
In-Reply-To: <2c1804d7-256e-4e3a-aa8e-d2cf4cea82can@googlegroups.com>
 by: Chris M. Thomasson - Thu, 20 Jul 2023 20:04 UTC

On 7/20/2023 5:39 AM, minf...@arcor.de wrote:
> David Brown schrieb am Donnerstag, 20. Juli 2023 um 11:43:00 UTC+2:
>> On 19/07/2023 22:49, Bart wrote:
>>> On 19/07/2023 20:47, Ben Bacarisse wrote:
>>>> David Brown <david...@hesbynett.no> writes:
>>>>
>>>>> On 19/07/2023 18:22, Bart wrote:
>>>>>> On 19/07/2023 15:27, David Brown wrote:
>>>>>> > On 19/07/2023 13:07, Bart wrote:
>>>>>> > For the language definition, it is about what makes sense in the
>>>>>> code. C
>>>>>> > is a typed language. It does not make it very hard to mess
>>>>>> around with
>>>>>> > types, and it does not have good support for making your own
>>>>>> types that
>>>>>> > are convenient to use, but it /is/ a typed language. A float is
>>>>>> a float
>>>>>> > - it is not an int, and it does not make sense to use it as an int.
>>>>>> Isn't that how BCPL (an ancestor of C) worked? You just had chunks of
>>>>>> memory and defined what they represented by the operations you chose.
>>>>
>>>> Yes. a * b multiplies the integer values of two words. a #* b
>>>> multiplies the same words but interprets them as floating point. Being
>>>> word based, this aspect was very clumsy as you'd need another set of
>>>> operators to handle double precision floats.
>>>
>>> OCaml uses different operators too. * for integer multiply, *. for float.
>> That's interesting. Usually stronger typed languages are able to use
>> overloading to let you re-use the same operator (though they might not
>> let you mix types, such as multiplying an integer and a floating point
>> number). I think having different operators for different types would
>> quickly get ugly if you want to support lots of types (such as different
>> sized integers).
>
> Forth is stack-based. Say you have two items on the integer stack and two items
> on the fp-number stack. Overloading '+' doesn't work here because the compiler
> wouldn't know on which stack to operate.
>
> Its "queer" syntax is just a matter of getting used to it.

What is "queer" syntax?

Re: you think rust may outthrone c?

<u9c43j$2rpbs$6@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26387&group=comp.lang.c#26387

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 20 Jul 2023 13:06:10 -0700
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <u9c43j$2rpbs$6@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<87sf9niqb6.fsf@bsb.me.uk> <u923gr$tf08$1@dont-email.me>
<u92mms$12tmp$1@dont-email.me>
<5fbef78e-14f8-43c4-afaf-17fa5bad12bdn@googlegroups.com>
<b54f60b1-6db7-4ecc-a1f6-b03c78c291een@googlegroups.com>
<u94eb1$1c2vr$1@dont-email.me> <874jm2tbkt.fsf@nosuchdomain.example.com>
<u94hip$1cdbp$1@dont-email.me> <87lefeukpy.fsf@bsb.me.uk>
<u94pch$1dpd6$1@dont-email.me> <87edl6uf9y.fsf@bsb.me.uk>
<u95rn3$1k9hq$1@dont-email.me> <87r0p4tyx4.fsf@bsb.me.uk>
<u98g5n$2469a$1@dont-email.me> <u98rs9$26ae9$1@dont-email.me>
<87mszrsx6z.fsf@bsb.me.uk> <u99alq$292ke$1@dont-email.me>
<87wmyvr9kg.fsf@bsb.me.uk> <87fs5jseuv.fsf@nosuchdomain.example.com>
<20230719160546.668@kylheku.com> <87bkg7s5zt.fsf@nosuchdomain.example.com>
<b5f1c671-ed9c-4bc4-b899-552d71335037n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 20 Jul 2023 20:06:11 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="548cb02f8621473374aa0fef010fdab5";
logging-data="3007868"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Qe2WaATL5cMdOszcdWcUnNZJuer0DFaI="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:bK4gknGFhS+uN7zGsNfFgKJTIOE=
Content-Language: en-US
In-Reply-To: <b5f1c671-ed9c-4bc4-b899-552d71335037n@googlegroups.com>
 by: Chris M. Thomasson - Thu, 20 Jul 2023 20:06 UTC

On 7/20/2023 1:46 AM, Malcolm McLean wrote:
> On Thursday, 20 July 2023 at 02:54:03 UTC+1, Keith Thompson wrote:
>> Kaz Kylheku <864-11...@kylheku.com> writes:
>>> On 2023-07-19, Keith Thompson <Keith.S.T...@gmail.com> wrote:
>>>> Ben Bacarisse <ben.u...@bsb.me.uk> writes:
[...]
> One machine I worked on (the Nintendo 64)

Nice!

> had nine bits per byte. However
> the C compiler and most assembly instructions only used 8 bits.The 9th
> bit was used by the GPU and you could access it using special machine
> instructions.
> It wasn't used for trap representations of course. But 32 logical bits doesn't necessarily
> means 32 physical bits.

Re: you think rust may outthrone c?

<u9c4n5$2s0hp$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26388&group=comp.lang.c#26388

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: nos...@please.ty (jak)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 20 Jul 2023 22:16:34 +0200
Organization: A noiseless patient Spider
Lines: 74
Message-ID: <u9c4n5$2s0hp$1@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u8p0kv$h9r$1@matrix.hispagatos.org> <20230713104558.553@kylheku.com>
<u8phd0$3niul$1@dont-email.me> <UpYrM.257503$W7d4.2562@fx18.iad>
<u8pmt9$3o80g$1@dont-email.me> <u8q0q4$3p89v$1@dont-email.me>
<u8qqpv$3v3pg$1@dont-email.me> <u8r94r$dn9$1@dont-email.me>
<u8rcu9$qd2$1@dont-email.me> <u8rdrf$uca$1@dont-email.me>
<20230714140153.112@kylheku.com> <u8sf33$4nc3$1@dont-email.me>
<u8u3ge$cscl$1@dont-email.me> <87sf9oye05.fsf@nosuchdomain.example.com>
<a189a8ff-5e91-43b7-9601-1f29b6a667bfn@googlegroups.com>
<u90c0s$nr2u$1@dont-email.me>
<0ff5dfe1-de32-4dae-872e-5401a3c04c97n@googlegroups.com>
<u90u5r$pnad$1@dont-email.me> <87sf9niqb6.fsf@bsb.me.uk>
<u923gr$tf08$1@dont-email.me> <87mszvwbwl.fsf@bsb.me.uk>
<ea263e0e-b936-43d2-a4b2-9fe62ccccce9n@googlegroups.com>
<u93dlc$158qe$1@dont-email.me> <20230717113353.356@kylheku.com>
<u9bv2c$2r3ek$1@dont-email.me> <20230720121839.520@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 20 Jul 2023 20:16:37 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="28e50f7c17c8863d1d047074630c4c2d";
logging-data="3015225"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19YSYdnL6tHef/WqUZUtUBV"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.16
Cancel-Lock: sha1:B9K0Pu9q3BadCCaKe0Nruk3nSok=
In-Reply-To: <20230720121839.520@kylheku.com>
 by: jak - Thu, 20 Jul 2023 20:16 UTC

Kaz Kylheku ha scritto:
> On 2023-07-20, jak <nospam@please.ty> wrote:
>> Kaz Kylheku ha scritto:
>>> With C99 syntax, we can do that as one expression:
>>>
>>> #include <stdio.h>
>>>
>>> #define union_cast(to_type, from_type, value) \
>>> ((union { to_type to; from_type from; }){ .from = (value) }.to)
>>>
>>
>> Around the web I found this macro similar to yours:
>>
>> #define chk_sign(from_type, value) \
>> (!!(union { from_type from; \
>> struct { \
>> uint64_t rest : ((sizeof(from_type) * CHAR_BIT) -
>> 1); \
>> uint64_t sign : 1; \
>> } to; \
>> }) { .from = (value) }.to.sign)
>
> That alone not work on anything but big endian machines.
>
> Look at that file again to see whether it has something like
>
> #if BIG_ENDIAN
> #define chk_sign ... // the above definition
> #else
> #define chk_sign ... // alternative with rearranged union
> #endif
>
> A common allocation strategy for bitfields is that they follow
> endianness. When a 1-bit field is allocated into a brand new
> bitfield packing cell (which could be int-sized or whatever),
> it goes into the lowest-offset byte first.
>
> Within a byte, the order goes from MSB to LSB on big endian,
> and LSB to msb on little endian:
>
> Thus, here if we put 0x80 into x:
>
> union {
> unsigned char x;
> unsigned y : 1;
> };
>
> then y will be 1 on big endian, 0 on little.
>
> We cannot necessarily deduce all this from the ISO C standard, but
> that's the way it is with GCC.
>
> In device drivers it's not uncommon to see this:
>
> struct foo_registers {
> // 32 bit status word
> #if BIG_ENDIAN
> unsigned int on_fire : 1;
> unsigned int read_ready : 1;
> unsigned int locked_up : 1;
> /// ... 29 more
> #else
> /// ... 29 more
> unsigned int locked_up : 1;
> unsigned int read_ready : 1;
> unsigned int on_fire : 1;
> #endif
> }
>

In fact, it is how you are saying but #if BIG_ENDIAN was distant several
lines and I have not seen it. My bad.

Re: you think rust may outthrone c?

<87tttyqkf1.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26393&group=comp.lang.c#26393

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 20 Jul 2023 15:37:22 -0700
Organization: None to speak of
Lines: 40
Message-ID: <87tttyqkf1.fsf@nosuchdomain.example.com>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<87sf9niqb6.fsf@bsb.me.uk> <u923gr$tf08$1@dont-email.me>
<u92mms$12tmp$1@dont-email.me>
<5fbef78e-14f8-43c4-afaf-17fa5bad12bdn@googlegroups.com>
<b54f60b1-6db7-4ecc-a1f6-b03c78c291een@googlegroups.com>
<u94eb1$1c2vr$1@dont-email.me>
<874jm2tbkt.fsf@nosuchdomain.example.com>
<u94hip$1cdbp$1@dont-email.me> <87lefeukpy.fsf@bsb.me.uk>
<u94pch$1dpd6$1@dont-email.me> <87edl6uf9y.fsf@bsb.me.uk>
<u95rn3$1k9hq$1@dont-email.me> <87r0p4tyx4.fsf@bsb.me.uk>
<c52e1506-b0a5-4e5b-99c0-5e79c5305a3an@googlegroups.com>
<87o7k8rzh5.fsf@nosuchdomain.example.com>
<0fa83b40-26e6-427a-ba84-6cf8ac33172an@googlegroups.com>
<u98odb$25mj8$1@dont-email.me>
<87jzuvsg7q.fsf@nosuchdomain.example.com>
<a3781781-14c3-45be-8e5b-759c19fb456en@googlegroups.com>
<u9as55$2knb8$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="2370f913b850030e0527dd0f7396627d";
logging-data="3058071"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/6Bf1+k6zYl7vuszh9OHU9"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:3pyf8ftcMzESWWSjqRZcVjiiw/0=
sha1:OZ/nGFznlVjYxuOgdceIPzK+bvE=
 by: Keith Thompson - Thu, 20 Jul 2023 22:37 UTC

David Brown <david.brown@hesbynett.no> writes:
> On 20/07/2023 00:23, Malcolm McLean wrote:
>> On Wednesday, 19 July 2023 at 23:13:17 UTC+1, Keith Thompson wrote:
[...]
>>> Agreed. Here's an example:
>>>
>>> #include <stdio.h>
>>> #include <limits.h>
>>> int main(void) {
>>> int n = INT_MAX;
>>> if (n + 1 > n) {
>>> printf("%d > %d\n", n + 1, n);
>>> }
>>> else {
>>> printf("%d <= %d\n", n + 1, n);
>>> }
>>> }
>>>
>>> With gcc (without -fwrapv), this program prints (at all optimization
>>> levels):
>>>
>>> -2147483648 > 2147483647
>>>
>> I get the output
>> -2147483648 <= 2147483647
>> Adnittedly I'm using a Mac and the command "gcc" actually invokes clang.
>
> The moon is in a different phase where you are.

Not necessarily; my results using clang matched Malcolm's.

> But you are demonstrating Keith's point - signed integer overflow is
> UB, and there is no way to predict the outcome. It will vary by
> compiler, flags, details of the code, and of course, by the phase of
> the moon.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: you think rust may outthrone c?

<87pm4mqjmb.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26394&group=comp.lang.c#26394

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 20 Jul 2023 15:54:36 -0700
Organization: None to speak of
Lines: 12
Message-ID: <87pm4mqjmb.fsf@nosuchdomain.example.com>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<b54f60b1-6db7-4ecc-a1f6-b03c78c291een@googlegroups.com>
<u94eb1$1c2vr$1@dont-email.me>
<874jm2tbkt.fsf@nosuchdomain.example.com>
<u94hip$1cdbp$1@dont-email.me> <87lefeukpy.fsf@bsb.me.uk>
<u94pch$1dpd6$1@dont-email.me> <87edl6uf9y.fsf@bsb.me.uk>
<u95rn3$1k9hq$1@dont-email.me> <87r0p4tyx4.fsf@bsb.me.uk>
<u98g5n$2469a$1@dont-email.me> <u98rs9$26ae9$1@dont-email.me>
<u992jq$27kpu$1@dont-email.me> <u99bua$29a16$1@dont-email.me>
<87ilafr8e0.fsf@bsb.me.uk> <u99i9b$2ac5l$1@dont-email.me>
<u9avim$2l5mt$3@dont-email.me>
<2c1804d7-256e-4e3a-aa8e-d2cf4cea82can@googlegroups.com>
<u9bas2$2n8dl$1@dont-email.me> <u9berv$2o345$1@dont-email.me>
<u9bmvs$2pmgm$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="2370f913b850030e0527dd0f7396627d";
logging-data="3058071"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Fmk3nePL6uTcevv6qf0eO"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:a49wAceG5Q83UL+U1EGb+6N4l2c=
sha1:xbEEyn7HoI97gNWxJVeI/OtaAqY=
 by: Keith Thompson - Thu, 20 Jul 2023 22:54 UTC

David Brown <david.brown@hesbynett.no> writes:
[...]
> Like Yoda must you think if Forth to understand you are. Or something
> like that!
[...]

An old bumper sticker: "4TH ♥ IF HONK THEN"

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: you think rust may outthrone c?

<u9cfmj$2trto$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26396&group=comp.lang.c#26396

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Fri, 21 Jul 2023 00:24:03 +0100
Organization: A noiseless patient Spider
Lines: 54
Message-ID: <u9cfmj$2trto$1@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u90c0s$nr2u$1@dont-email.me>
<0ff5dfe1-de32-4dae-872e-5401a3c04c97n@googlegroups.com>
<u90u5r$pnad$1@dont-email.me> <87sf9niqb6.fsf@bsb.me.uk>
<u923gr$tf08$1@dont-email.me> <u92mms$12tmp$1@dont-email.me>
<5fbef78e-14f8-43c4-afaf-17fa5bad12bdn@googlegroups.com>
<b54f60b1-6db7-4ecc-a1f6-b03c78c291een@googlegroups.com>
<u94eb1$1c2vr$1@dont-email.me> <874jm2tbkt.fsf@nosuchdomain.example.com>
<u94hip$1cdbp$1@dont-email.me> <87lefeukpy.fsf@bsb.me.uk>
<u94pch$1dpd6$1@dont-email.me> <87edl6uf9y.fsf@bsb.me.uk>
<u95rn3$1k9hq$1@dont-email.me> <87r0p4tyx4.fsf@bsb.me.uk>
<c52e1506-b0a5-4e5b-99c0-5e79c5305a3an@googlegroups.com>
<87o7k8rzh5.fsf@nosuchdomain.example.com>
<0fa83b40-26e6-427a-ba84-6cf8ac33172an@googlegroups.com>
<u98odb$25mj8$1@dont-email.me> <87jzuvsg7q.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 20 Jul 2023 23:24:03 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="0b33e2ae51c4dd97523406dbb7e485ce";
logging-data="3076024"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/wPvuZiYFGWNHgytQfYYOfrsmE2UbcS4c="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:/8OCuyu0Ai9CTks42UaZU/stS10=
In-Reply-To: <87jzuvsg7q.fsf@nosuchdomain.example.com>
 by: Bart - Thu, 20 Jul 2023 23:24 UTC

On 19/07/2023 23:12, Keith Thompson wrote:
> David Brown <david.brown@hesbynett.no> writes:

>> However, when people talk about two's complement signed integers, they
>> are sometimes talking about signed arithmetic overflows. This is a
>> very different matter from the representation of the types. And while
>> almost all current processors will use two's complement wrapping in
>> their signed arithmetic instructions, C (including C23) does /not/
>> guarantee any behaviour for overflows, and C compilers do not, as a
>> rule, guarantee any behaviour for overflows. Many optimising
>> compilers will optimise code on the assumption that signed integer
>> arithmetic does not overflow. This is not new - I first saw it nearly
>> 30 years ago. It is not just gcc or clang - MSVC also does such
>> optimisations. The only compilers I know about for which you can rely
>> on wrapping behaviour are gcc and clang with the "-fwrapv" flag
>> enabled.
>
> Agreed. Here's an example:
>
> #include <stdio.h>
> #include <limits.h>
> int main(void) {
> int n = INT_MAX;
> if (n + 1 > n) {
> printf("%d > %d\n", n + 1, n);
> }
> else {
> printf("%d <= %d\n", n + 1, n);
> }
> }
>
> With gcc (without -fwrapv), this program prints (at all optimization
> levels):
>
> -2147483648 > 2147483647

This is a fake result. gcc even at -O0 does not actually attempt to do
the comparison, it just calls that first printf anyway. Code for the
other printf does not appear in the compiler output (this is version 10.x).

That is the case even when `n` is external. It assumes that n+1 must be
greater than n, always.

If I compare two externs a and b (set elsewhere to INT_MAX+1 and
INT_MAX), then I get <= like my compilers.

This means that gcc can give inconsistent results when apparently
comparing the same two pairs of values.

TBH I found it hard to predict the results of x64's cmp followed by jle.
But what's not hard however is predicting the result of INT_MAX+1. My
tools which don't try to be clever, will give more consistent results.

gcc assumes ints don't wrap, but sometimes they do.

Re: you think rust may outthrone c?

<87h6pyqgnp.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26397&group=comp.lang.c#26397

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 20 Jul 2023 16:58:34 -0700
Organization: None to speak of
Lines: 60
Message-ID: <87h6pyqgnp.fsf@nosuchdomain.example.com>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u90u5r$pnad$1@dont-email.me> <87sf9niqb6.fsf@bsb.me.uk>
<u923gr$tf08$1@dont-email.me> <u92mms$12tmp$1@dont-email.me>
<5fbef78e-14f8-43c4-afaf-17fa5bad12bdn@googlegroups.com>
<b54f60b1-6db7-4ecc-a1f6-b03c78c291een@googlegroups.com>
<u94eb1$1c2vr$1@dont-email.me>
<874jm2tbkt.fsf@nosuchdomain.example.com>
<u94hip$1cdbp$1@dont-email.me> <87lefeukpy.fsf@bsb.me.uk>
<u94pch$1dpd6$1@dont-email.me> <87edl6uf9y.fsf@bsb.me.uk>
<u95rn3$1k9hq$1@dont-email.me> <87r0p4tyx4.fsf@bsb.me.uk>
<c52e1506-b0a5-4e5b-99c0-5e79c5305a3an@googlegroups.com>
<87o7k8rzh5.fsf@nosuchdomain.example.com>
<0fa83b40-26e6-427a-ba84-6cf8ac33172an@googlegroups.com>
<u98odb$25mj8$1@dont-email.me>
<87jzuvsg7q.fsf@nosuchdomain.example.com>
<u9cfmj$2trto$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="2370f913b850030e0527dd0f7396627d";
logging-data="3079342"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/7SqCXwCWkOyrj6DK5MByr"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:Im7sa5yHUf9ZGIIYK4I+nB2evvs=
sha1:jQoW7oz2kmuMh101bmigpfOG+LI=
 by: Keith Thompson - Thu, 20 Jul 2023 23:58 UTC

Bart <bc@freeuk.com> writes:
> On 19/07/2023 23:12, Keith Thompson wrote:
[...]
>> Agreed. Here's an example:
>>
>> #include <stdio.h>
>> #include <limits.h>
>> int main(void) {
>> int n = INT_MAX;
>> if (n + 1 > n) {
>> printf("%d > %d\n", n + 1, n);
>> }
>> else {
>> printf("%d <= %d\n", n + 1, n);
>> }
>> }
>>
>> With gcc (without -fwrapv), this program prints (at all optimization
>> levels):
>>
>> -2147483648 > 2147483647
>
> This is a fake result.

No, it's not. It's exactly the output the program produced when I
compiled and ran it.

Please explain what you mean by "fake result". Are you insinuating that
I lied about it?

> gcc even at -O0 does not actually attempt to do
> the comparison, it just calls that first printf anyway. Code for the
> other printf does not appear in the compiler output (this is version 10.x).
>
> That is the case even when `n` is external. It assumes that n+1 must
> be greater than n, always.

Which is a valid assumption.

> If I compare two externs a and b (set elsewhere to INT_MAX+1 and
> INT_MAX), then I get <= like my compilers.

That's not surprising. (Of course nothing was actually set to
INT_MAX+1; something was set to the undefined result of evaluating that
expression.)

> This means that gcc can give inconsistent results when apparently
> comparing the same two pairs of values.

Certainly. That kind of thing is completely unsurprising for code whose
behavior is undefined.

[...]

I can explain the language rules to you. I can't understand them for you.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: you think rust may outthrone c?

<6317c8eb-a3bd-41ad-b9fb-e07a51505febn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26398&group=comp.lang.c#26398

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:15c8:b0:403:a6f7:aa16 with SMTP id d8-20020a05622a15c800b00403a6f7aa16mr1957qty.10.1689899432321;
Thu, 20 Jul 2023 17:30:32 -0700 (PDT)
X-Received: by 2002:a9d:7749:0:b0:6b8:c631:5c5a with SMTP id
t9-20020a9d7749000000b006b8c6315c5amr651807otl.4.1689899431966; Thu, 20 Jul
2023 17:30:31 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Thu, 20 Jul 2023 17:30:31 -0700 (PDT)
In-Reply-To: <87h6pyqgnp.fsf@nosuchdomain.example.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:e4c9:1be9:910a:4246;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:e4c9:1be9:910a:4246
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u90u5r$pnad$1@dont-email.me> <87sf9niqb6.fsf@bsb.me.uk> <u923gr$tf08$1@dont-email.me>
<u92mms$12tmp$1@dont-email.me> <5fbef78e-14f8-43c4-afaf-17fa5bad12bdn@googlegroups.com>
<b54f60b1-6db7-4ecc-a1f6-b03c78c291een@googlegroups.com> <u94eb1$1c2vr$1@dont-email.me>
<874jm2tbkt.fsf@nosuchdomain.example.com> <u94hip$1cdbp$1@dont-email.me>
<87lefeukpy.fsf@bsb.me.uk> <u94pch$1dpd6$1@dont-email.me> <87edl6uf9y.fsf@bsb.me.uk>
<u95rn3$1k9hq$1@dont-email.me> <87r0p4tyx4.fsf@bsb.me.uk> <c52e1506-b0a5-4e5b-99c0-5e79c5305a3an@googlegroups.com>
<87o7k8rzh5.fsf@nosuchdomain.example.com> <0fa83b40-26e6-427a-ba84-6cf8ac33172an@googlegroups.com>
<u98odb$25mj8$1@dont-email.me> <87jzuvsg7q.fsf@nosuchdomain.example.com>
<u9cfmj$2trto$1@dont-email.me> <87h6pyqgnp.fsf@nosuchdomain.example.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6317c8eb-a3bd-41ad-b9fb-e07a51505febn@googlegroups.com>
Subject: Re: you think rust may outthrone c?
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Fri, 21 Jul 2023 00:30:32 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 62
 by: Malcolm McLean - Fri, 21 Jul 2023 00:30 UTC

On Friday, 21 July 2023 at 00:58:50 UTC+1, Keith Thompson wrote:
> Bart <b...@freeuk.com> writes:
> > On 19/07/2023 23:12, Keith Thompson wrote:
> [...]
> >> Agreed. Here's an example:
> >>
> >> #include <stdio.h>
> >> #include <limits.h>
> >> int main(void) {
> >> int n = INT_MAX;
> >> if (n + 1 > n) {
> >> printf("%d > %d\n", n + 1, n);
> >> }
> >> else {
> >> printf("%d <= %d\n", n + 1, n);
> >> }
> >> }
> >>
> >> With gcc (without -fwrapv), this program prints (at all optimization
> >> levels):
> >>
> >> -2147483648 > 2147483647
> >
> > This is a fake result.
> No, it's not. It's exactly the output the program produced when I
> compiled and ran it.
>
> Please explain what you mean by "fake result". Are you insinuating that
> I lied about it?
> > gcc even at -O0 does not actually attempt to do
> > the comparison, it just calls that first printf anyway. Code for the
> > other printf does not appear in the compiler output (this is version 10.x).
> >
> > That is the case even when `n` is external. It assumes that n+1 must
> > be greater than n, always.
> Which is a valid assumption.
>
Try this one.

#include <stdio.h>
#include <stdint.h>
#include <string.h>

int main(void)
{ uint32_t nanpattern = 0x7f801234;
float x;

memcpy(&x, &nanpattern, 4);
printf("x %f\n", x);
if (x + 1 > x)
{
printf("Doesn't honour nan\n");
}
else
{
printf("Nan handled correctly\n");
}

return 0;
}

If it behaves in the same way then it is bugged.

Re: you think rust may outthrone c?

<87cz0mqe90.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26399&group=comp.lang.c#26399

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 20 Jul 2023 17:50:35 -0700
Organization: None to speak of
Lines: 47
Message-ID: <87cz0mqe90.fsf@nosuchdomain.example.com>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u923gr$tf08$1@dont-email.me> <u92mms$12tmp$1@dont-email.me>
<5fbef78e-14f8-43c4-afaf-17fa5bad12bdn@googlegroups.com>
<b54f60b1-6db7-4ecc-a1f6-b03c78c291een@googlegroups.com>
<u94eb1$1c2vr$1@dont-email.me>
<874jm2tbkt.fsf@nosuchdomain.example.com>
<u94hip$1cdbp$1@dont-email.me> <87lefeukpy.fsf@bsb.me.uk>
<u94pch$1dpd6$1@dont-email.me> <87edl6uf9y.fsf@bsb.me.uk>
<u95rn3$1k9hq$1@dont-email.me> <87r0p4tyx4.fsf@bsb.me.uk>
<c52e1506-b0a5-4e5b-99c0-5e79c5305a3an@googlegroups.com>
<87o7k8rzh5.fsf@nosuchdomain.example.com>
<0fa83b40-26e6-427a-ba84-6cf8ac33172an@googlegroups.com>
<u98odb$25mj8$1@dont-email.me>
<87jzuvsg7q.fsf@nosuchdomain.example.com>
<u9cfmj$2trto$1@dont-email.me>
<87h6pyqgnp.fsf@nosuchdomain.example.com>
<6317c8eb-a3bd-41ad-b9fb-e07a51505febn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="2370f913b850030e0527dd0f7396627d";
logging-data="3102780"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+NuYHN/dEl5ZJ6sHs7OGkj"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:U7J1rZi1O91B2gTt4PBlMw00L0M=
sha1:2V11Dewis9RSeOfxy09K2/8dnzc=
 by: Keith Thompson - Fri, 21 Jul 2023 00:50 UTC

Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
[...]
> Try this one.
>
> #include <stdio.h>
> #include <stdint.h>
> #include <string.h>
>
> int main(void)
> {
> uint32_t nanpattern = 0x7f801234;
> float x;
>
> memcpy(&x, &nanpattern, 4);
> printf("x %f\n", x);
> if (x + 1 > x)
> {
> printf("Doesn't honour nan\n");
> }
> else
> {
> printf("Nan handled correctly\n");
> }
>
> return 0;
> }

On my system, it prints:
x nan
Nan handled correctly
when compiled with both gcc and clang at all optimization levels.

> If it behaves in the same way then it is bugged.

You may be right (assuming 0x7f801234 copied into a float yields a NaN;
I don't think the C standard specifies that), but I haven't given it
much though.

For any two valid integer values x and y, exactly one of x<y, x==y, x>y
is true. That's not the case for floating-point values, which means
that a compiler cannot assume (x + 1 > x) without information about the
value of x (given an implementation that supports NaNs).

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: you think rust may outthrone c?

<u9cld3$2uof8$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26400&group=comp.lang.c#26400

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Fri, 21 Jul 2023 02:01:23 +0100
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <u9cld3$2uof8$1@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u90u5r$pnad$1@dont-email.me> <87sf9niqb6.fsf@bsb.me.uk>
<u923gr$tf08$1@dont-email.me> <u92mms$12tmp$1@dont-email.me>
<5fbef78e-14f8-43c4-afaf-17fa5bad12bdn@googlegroups.com>
<b54f60b1-6db7-4ecc-a1f6-b03c78c291een@googlegroups.com>
<u94eb1$1c2vr$1@dont-email.me> <874jm2tbkt.fsf@nosuchdomain.example.com>
<u94hip$1cdbp$1@dont-email.me> <87lefeukpy.fsf@bsb.me.uk>
<u94pch$1dpd6$1@dont-email.me> <87edl6uf9y.fsf@bsb.me.uk>
<u95rn3$1k9hq$1@dont-email.me> <87r0p4tyx4.fsf@bsb.me.uk>
<c52e1506-b0a5-4e5b-99c0-5e79c5305a3an@googlegroups.com>
<87o7k8rzh5.fsf@nosuchdomain.example.com>
<0fa83b40-26e6-427a-ba84-6cf8ac33172an@googlegroups.com>
<u98odb$25mj8$1@dont-email.me> <87jzuvsg7q.fsf@nosuchdomain.example.com>
<u9cfmj$2trto$1@dont-email.me> <87h6pyqgnp.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 21 Jul 2023 01:01:23 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="0b33e2ae51c4dd97523406dbb7e485ce";
logging-data="3105256"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ChXd2M48+xFKSXv0TMrNSWZO74tLAbyw="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:wHprxxVMkboEbbimaLyBSDviF4Y=
In-Reply-To: <87h6pyqgnp.fsf@nosuchdomain.example.com>
 by: Bart - Fri, 21 Jul 2023 01:01 UTC

On 21/07/2023 00:58, Keith Thompson wrote:
> Bart <bc@freeuk.com> writes:
>> On 19/07/2023 23:12, Keith Thompson wrote:
> [...]
>>> Agreed. Here's an example:
>>>
>>> #include <stdio.h>
>>> #include <limits.h>
>>> int main(void) {
>>> int n = INT_MAX;
>>> if (n + 1 > n) {
>>> printf("%d > %d\n", n + 1, n);
>>> }
>>> else {
>>> printf("%d <= %d\n", n + 1, n);
>>> }
>>> }
>>>
>>> With gcc (without -fwrapv), this program prints (at all optimization
>>> levels):
>>>
>>> -2147483648 > 2147483647
>>
>> This is a fake result.
>
> No, it's not. It's exactly the output the program produced when I
> compiled and ran it.
>
> Please explain what you mean by "fake result". Are you insinuating that
> I lied about it?

No. gcc on my machine hard-codes that output without bothering to
execute the comparison to see what the hardware does with it.

Because it makes an assumption about the result of comparing n+1 with n.
If those same two values were compared via variables where it did not
not know their values and their relationship, it would be forced to do
an actual comparison.

On my machine, that produced a different result even still comparing
values of INT_MAX+1 with INT_MAX.

Re: you think rust may outthrone c?

<878rbaqch6.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26401&group=comp.lang.c#26401

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 20 Jul 2023 18:28:53 -0700
Organization: None to speak of
Lines: 59
Message-ID: <878rbaqch6.fsf@nosuchdomain.example.com>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u923gr$tf08$1@dont-email.me> <u92mms$12tmp$1@dont-email.me>
<5fbef78e-14f8-43c4-afaf-17fa5bad12bdn@googlegroups.com>
<b54f60b1-6db7-4ecc-a1f6-b03c78c291een@googlegroups.com>
<u94eb1$1c2vr$1@dont-email.me>
<874jm2tbkt.fsf@nosuchdomain.example.com>
<u94hip$1cdbp$1@dont-email.me> <87lefeukpy.fsf@bsb.me.uk>
<u94pch$1dpd6$1@dont-email.me> <87edl6uf9y.fsf@bsb.me.uk>
<u95rn3$1k9hq$1@dont-email.me> <87r0p4tyx4.fsf@bsb.me.uk>
<c52e1506-b0a5-4e5b-99c0-5e79c5305a3an@googlegroups.com>
<87o7k8rzh5.fsf@nosuchdomain.example.com>
<0fa83b40-26e6-427a-ba84-6cf8ac33172an@googlegroups.com>
<u98odb$25mj8$1@dont-email.me>
<87jzuvsg7q.fsf@nosuchdomain.example.com>
<u9cfmj$2trto$1@dont-email.me>
<87h6pyqgnp.fsf@nosuchdomain.example.com>
<u9cld3$2uof8$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="2370f913b850030e0527dd0f7396627d";
logging-data="3110105"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+CDi0crSf4t8Y+cCcaILwI"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:siS8i2lkKDyYA5UxGbXI/DkeljY=
sha1:nNDhX7aBJYYHPlhvg7sIgAhcT+c=
 by: Keith Thompson - Fri, 21 Jul 2023 01:28 UTC

Bart <bc@freeuk.com> writes:
> On 21/07/2023 00:58, Keith Thompson wrote:
>> Bart <bc@freeuk.com> writes:
>>> On 19/07/2023 23:12, Keith Thompson wrote:
>> [...]
>>>> Agreed. Here's an example:
>>>>
>>>> #include <stdio.h>
>>>> #include <limits.h>
>>>> int main(void) {
>>>> int n = INT_MAX;
>>>> if (n + 1 > n) {
>>>> printf("%d > %d\n", n + 1, n);
>>>> }
>>>> else {
>>>> printf("%d <= %d\n", n + 1, n);
>>>> }
>>>> }
>>>>
>>>> With gcc (without -fwrapv), this program prints (at all optimization
>>>> levels):
>>>>
>>>> -2147483648 > 2147483647
>>>
>>> This is a fake result.
>> No, it's not. It's exactly the output the program produced when I
>> compiled and ran it.
>> Please explain what you mean by "fake result". Are you insinuating
>> that
>> I lied about it?
>
> No. gcc on my machine hard-codes that output without bothering to
> execute the comparison to see what the hardware does with it.

Are you saying that that's what you meant by "fake result"? Are you
saying there's something "fake" about not emitting an ADD instruction in
response to a C "+" operation? Is evaluating 2+2 at compile time
"fake"?

> Because it makes an assumption about the result of comparing n+1 with
> n. If those same two values were compared via variables where it did
> not not know their values and their relationship, it would be forced
> to do an actual comparison.

Yes. Are you under the impression I didn't know that? Do you think the
assumption is invalid, given that the code's behavior is undefined?

> On my machine, that produced a different result even still comparing
> values of INT_MAX+1 with INT_MAX.

And what exactly is your point?

Or are you just trying to make this look worse and more complicated than
it really is?

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: you think rust may outthrone c?

<87h6pyowz6.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=26402&group=comp.lang.c#26402

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Fri, 21 Jul 2023 02:49:01 +0100
Organization: A noiseless patient Spider
Lines: 125
Message-ID: <87h6pyowz6.fsf@bsb.me.uk>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u90u5r$pnad$1@dont-email.me> <87sf9niqb6.fsf@bsb.me.uk>
<u923gr$tf08$1@dont-email.me> <u92mms$12tmp$1@dont-email.me>
<5fbef78e-14f8-43c4-afaf-17fa5bad12bdn@googlegroups.com>
<b54f60b1-6db7-4ecc-a1f6-b03c78c291een@googlegroups.com>
<u94eb1$1c2vr$1@dont-email.me>
<874jm2tbkt.fsf@nosuchdomain.example.com>
<u94hip$1cdbp$1@dont-email.me> <87lefeukpy.fsf@bsb.me.uk>
<u94pch$1dpd6$1@dont-email.me> <87edl6uf9y.fsf@bsb.me.uk>
<u95rn3$1k9hq$1@dont-email.me> <87r0p4tyx4.fsf@bsb.me.uk>
<u98g5n$2469a$1@dont-email.me> <u98rs9$26ae9$1@dont-email.me>
<87mszrsx6z.fsf@bsb.me.uk> <u99alq$292ke$1@dont-email.me>
<87wmyvr9kg.fsf@bsb.me.uk> <u9atg7$2kv4f$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="4d6d411b072660d280bdd2ba4d2c5af7";
logging-data="3241835"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18PRzQCier82hldp8yvHTeg5Nw/YR5U2F0="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:Iy4TdnSBGIIuDhAU21ugYAeG76M=
sha1:sWbrNsmEer9CxVPQVp1CM0ULQEI=
X-BSB-Auth: 1.1475b456e963f4366117.20230721024901BST.87h6pyowz6.fsf@bsb.me.uk
 by: Ben Bacarisse - Fri, 21 Jul 2023 01:49 UTC

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

> On 19/07/2023 21:21, Ben Bacarisse wrote:
>> David Brown <david.brown@hesbynett.no> writes:
>>
>>> On 19/07/2023 18:06, Ben Bacarisse wrote:
>>>> David Brown <david.brown@hesbynett.no> writes:
>>>>
>>>>> On 19/07/2023 13:07, Bart wrote:
>> <cut>
>>>>>> For example (assume both are 32 bits):
>>>>>>      float* p = malloc(sizeof(float));
>>>>>>      int* q = (void*)(p);
>>>>>>      *q;        // is it this?
>>>>>> In this case, space for 4 bytes has been allocated. malloc doesn't know
>>>>>> if that space is for floats, ints, or anything else. I genuinely can't
>>>>>> see the problem.
>>>>>
>>>>> Please read section 6.5 of the standards, paragraphs 6 and 7. The details
>>>>> are more complicated for allocated space than for declared objects.
>>>>>
>>>>> The line "*q;" is, I believe, undefined behaviour - it is attempting to
>>>>> read an "int" object when no such object exists at that address. You would
>>>>> have the same problem evaluating "*p;" as no float object exists at that
>>>>> address either.
>>>>
>>>> I think you are right about *q being UB, but I don't think "no such
>>>> object exists" is a useful way to put it. I've not studied the details
>>>> of the new standard, but accessing an object with an indeterminate value
>>>> is probably still UB, but there's surely an object there if malloc
>>>> succeeds.
>>>
>>> By "no such object exists", I mean "no object of type int exists at that
>>> address". There is an object with size, but no declared or effective
>>> type.
>>>
>>> To be honest, I couldn't find a clear rule here. Attempting to use the
>>> value of an automatic storage variable while it is indeterminate is
>>> explicitly UB, but I saw no obvious paragraph in the standards (C17 or
>>> C23) about it.
>> I find that phrasing odd. It's "explicitly UB" but you could not find
>> where this was made explicit?
>
> It all sounded clear in my head when I wrote it, but I see my phrasing was
> not clear.
>
>
> For automatic storage variables, using the value while it is indeterminate
> is explicitly UB - from J.2 (a list of undefined behaviours):

Non-normative, as I am sure you know. And, as I said elsewhere, if it
accurately reflects the intent, then it explicitly excludes the case in
point with allocated storage.

> """
> The value of an object with automatic storage duration is used while it is
> indeterminate (6.2.4, 6.7.9, 6.8).
> """
>
> For allocated objects from malloc, I could not find any rules that say
> accessing the memory before something is stored in it is UB. I believe it
> is UB - and of course, something can be UB simply because there is no
> definition of its behaviour in the standards. But until I can see a clear
> rule, I would not call it "explicitly UB". And I believe the intention of
> J.2 is to summarise such "explicit UB" - if there were a clear rule here,
> it would probably be listed in J.2.
>
>
>> 6.2.6.1 p5 says (in part)
>> "Certain object representations need not represent a value of the
>> object type. If such a representation is read by an lvalue expression
>> that does not have character type, the behavior is undefined."
>> Elsewhere we can find wording to say that uninitialised local variables
>> and newly allocated storage contain indeterminate representations. This
>> includes the possibility of non-value representations.
>
> Using indeterminate values in uninitialised local variables is UB,
> regardless of whether or not there could be non-value representations
> supported by the hardware.

So everyone says, but no one has produced the normative text that says
so. I was trying to get there. I think there's some justification for
saying the something that is potentially UB could be called UB. It's
not a strong argument, but is there anything better? What's your
reasoning?

There's another case that has also come up before. It's often said that
conversion of an out-of-rang value to int is undefined, and indeed
Appendix J.2 p16 says "Conversion to or from an integer type produces a
value outside the range that can be represented (6.3.1.4)" but 6.3.1.4
only refers to the conversion between real and int types. It says --
explicitly -- that

int i = 1e123;

is undefined (for sane integer widths). But this:

int i = UINT_MAX;

is also a conversion "to or from an integer type" that (for the usual
sizes) "produces a value outside the range that can be represented".
But the normative text (6.3.1.3) says that if

"the new type is signed and the value cannot be represented in it;
either the result is implementation-defined or an
implementation-defined signal is raised"

so I tried the "if it /might/ UB it /is/ UB" argument on this one too in
the past. I'm not sure anyone bought it then either. I'm not sure I
buy it!

>> Thus it's tempting to consider *q as being "almost always well-defined"
>> but since my view is that the semantics of a construct should include
>> all the possibilities, the only meaning we can put on "int p;
>> printf("%d\n", p);" is "none".
>
> "No meaning" is, of course, just another way of saying "UB". But it's
> important, I think, to note that it is UB even on systems where non-value
> representations are not possible for ints. (i.e., almost every real-world
> system.)

We should only note it if it's true! Is it?

--
Ben.


devel / comp.lang.c / Re: you think rust may outthrone c?

Pages:123456789101112131415161718192021222324252627282930313233343536373839
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor