Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Your computer account is overdrawn. Please reauthorize.


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?

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

  copy mid

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

  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: Wed, 19 Jul 2023 20:47:19 +0100
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <87ilafr8e0.fsf@bsb.me.uk>
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>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="728d517973707f8d78d2018e7dcfa5fb";
logging-data="2418110"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18wI7N8BF4A5IFCoXhvK8lha+P6A3oruRc="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:MpD7r3UpeZeoHPhLex4YEjwILXs=
sha1:15QTtiZJeqC5ZOl4Xz1ajLdWFbc=
X-BSB-Auth: 1.aeec0f85859a87ad9888.20230719204719BST.87ilafr8e0.fsf@bsb.me.uk
 by: Ben Bacarisse - Wed, 19 Jul 2023 19:47 UTC

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. Indeed you'd need new
operators if you wanted to handle more than one size of integer.

Years ago I sketch out a design for a "modern" BCPL where the width of
objects could be stated. It was not very successful or I might have
tried to implement it.

> BCPL is before my time. But I think you are correct. C was intended to
> have stronger typing than BCPL.

You must be a youngster (for Usenet)! BCPL was still actively used for
R&D in Cambridge in the 1980s. My UG dissertation (1982) used BCPL.

I really used to like BCPL (I've not used for a while so I might not get
on with it anymore). It was surprisingly easy to use while remaining
very close to the metal. I looked at it's modern successor MCPL a while
back and I thought that looked interesting too.

--
Ben.

Re: you think rust may outthrone c?

<u99i9b$2ac5l$1@dont-email.me>

  copy mid

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

  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: Wed, 19 Jul 2023 21:49:48 +0100
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <u99i9b$2ac5l$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 19 Jul 2023 20:49:47 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b65d2679b994ae6bfe4de606f938ae11";
logging-data="2437301"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19yMuOfCw7ULE2OWux+Ln/zFhH96ToR4TY="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:Sgt3pnyM6QDZPTFpvxYB/JV/baQ=
In-Reply-To: <87ilafr8e0.fsf@bsb.me.uk>
 by: Bart - Wed, 19 Jul 2023 20:49 UTC

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.

I think that is to help with its type inference.

Re: you think rust may outthrone c?

<076c5a98-4eea-4cce-b0fc-7f1a6305fe94n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:5d91:0:b0:403:af80:8cce with SMTP id d17-20020ac85d91000000b00403af808ccemr96163qtx.10.1689803691897;
Wed, 19 Jul 2023 14:54:51 -0700 (PDT)
X-Received: by 2002:a05:6808:2025:b0:3a3:8c81:a86f with SMTP id
q37-20020a056808202500b003a38c81a86fmr29790482oiw.7.1689803691590; Wed, 19
Jul 2023 14:54:51 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Wed, 19 Jul 2023 14:54:51 -0700 (PDT)
In-Reply-To: <878rbbsw0o.fsf@bsb.me.uk>
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>
<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> <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> <874jm0t41e.fsf@bsb.me.uk>
<6425092b-d2ab-40c7-af6d-b1c1e73ef1cbn@googlegroups.com> <878rbbsw0o.fsf@bsb.me.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <076c5a98-4eea-4cce-b0fc-7f1a6305fe94n@googlegroups.com>
Subject: Re: you think rust may outthrone c?
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Wed, 19 Jul 2023 21:54:51 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 8289
 by: Malcolm McLean - Wed, 19 Jul 2023 21:54 UTC

On Wednesday, 19 July 2023 at 17:31:51 UTC+1, Ben Bacarisse wrote:
> Malcolm McLean <malcolm.ar...@gmail.com> writes:
>
> > On Wednesday, 19 July 2023 at 14:38:36 UTC+1, Ben Bacarisse wrote:
> >> Malcolm McLean <malcolm.ar...@gmail.com> writes:
> >>
> >> > On Wednesday, 19 July 2023 at 03:31:43 UTC+1, Ben Bacarisse wrote:
> >> >> Bart <b...@freeuk.com> writes:
> >> >>
> >> >> > On 18/07/2023 03:25, Ben Bacarisse wrote:
> >> >> >> Bart <b...@freeuk.com> writes:
> >> >> >>>
> >> >> You /are/ allowed to use it. The fact that it is undefined simply means
> >> >> that the definition of the language does not say what the code means.
> >> >> >> I really don't know what you hope to gain by saying obvious things like
> >> >> >> this other than to (incorrectly) imply that C -- the language -- is not
> >> >> >> defined by it's defining documents -- the ISO standards -- but by
> >> >> >> compiler options.
> >> >> >
> >> >> > I've given examples in the past where the same C program either:
> >> >> >
> >> >> > * Passed with 0 lines of errors or warnings
> >> >> >
> >> >> > * Passed with 28,000 lines of warnings and notes (on a 40Kloc input)
> >> >> So you are still trying to imply that C -- the language -- is not
> >> >> defined by it's defining documents -- the ISO standards -- but by
> >> >> compiler options. You are still wrong.
> >> >>
> >> > For someone implementing a compiler, the language is defined by the
> >> > standards document. But for someone who is not implementing a
> >> > compiler, the language is ultimatelt defined by the behaviour of
> >> > compilers.
> >> Your use of the definite article is permitting a confusion to go
> >> unnoticed. I would say that you are talking about two languages here:
> >> there is the C language (defined by the standards) and the language
> >> implemented by the compiler. We usually hope that they are very
> >> similar.
> >>
> >> The language implemented by the compiler is obviously very important in
> >> practice, but it's almost impossible to talk about it because it
> >> includes everything from bugs to misunderstandings of the standards.
> >>
> > It's also because the standard has to include every extant
> > architecture,
> I'm not sure what "it" refers to here so I'll leave this bit alone...
> > and maybe some which don't exist but theoretically could exist, like
> > Fibonacci representation machines. Whilst in fact you can probably
> > rely on features like CHAR_BIT being exactly eight. The standard
> > doesn't guarantee it, but the vast majority of achitectures make it
> > natural, and on big mainframes that don't allow 8 bit memory access,
> > in fact C compilers put the program through ANDs and ORs to create 8
> > bit chars, because otherwise too much code breaks. Only digital
> > signals processing chips have wider chars, and they can't run general
> > purpose programs anyway.
> >>
> >> In that sense, this second language is defined only by the compiler
> >> source code -- it's still not defined by the options. Bart wants to
> >> spread confusion by suggesting that C is a language defined by compiler
> >> options.
> >>
> > It is a bit of an odd situation. If we write a program which branches
> > if a char is negative, it will produce one output if we use the
> > "signed chars" option and another if we use the "unsigned chars"
> > option. So two executables with the same source and written in the
> > same language produce different output.
> Yes, but I am surprised you think that's odd. Maybe I think about the
> meaning of programs in very different terms to you. In formal
> semantics, there's no problem stating that there is more than one
> possible output, and when being informal you just need to adjust the
> words a bit. The "meaning" of this program:
>
> #include <stdio.h>
>
> int main(void) { printf("%u\n", -1u); }
>
> is "print the decimal representation of the largest unsigned int". It's
> not "print 4294967295" or "print 65535" (or any of the other
> possibilities).
>
The intention of the programmer might be to print the largest unsigned int,
or it might be to print 65535. If it's the first, then it's a type of meta program,
examining the characteristics of the program itself. And whilst it's possible that
an option could toggle between 32 bit and 16 bit ints, it's unlikely, because
you create too many problems for the linker. On different machines the same
program might have different results, but that's to be expected. If two machines
have different floating point hardware, then you'd expect slightly different output
from well-written programs, and it's posible to have radically different output
from badly-written programs.
On the other hand, consider this.

int ch = fgetc(fp);

/* quick hack, if we run out of input use commandline */
if (ch == EOF)
ch = argv[1][0];

if (ch < 32)
/* control character, process here */

The quick hack has of course broken the code. Unless the "signed char" option
is turned off. I do find this odd behaviour and difficult to accept.
>
> > So you can argue that in fact
> > the language can't be the same. Or you can argue, as you have done,
> > that computer languages allow for a sort of ambiguity which we don't
> > see in natural languages.
> I am not arguing that. For one thing, I don't consider "print the
> decimal representation of the largest unsigned int" to be ambiguous, but
> even if you do consider it so, it is ambiguous in a very particular
> sense, quite unlike most ambiguities in natural language.
>
In natural language your ambiguity is "does this mean the largest unsigned int
in existence, which is probably 2^128 -1, or the largest unsigned int on the
partiuclar machine we are discussing?" You need context to know the answer,
and of course in this case, you mean the second. The computer code is
ambiguous because we can't tell what the output will be from examining
the source code.Whilst "out of memory" is a special case which has to exist for
fundamental technical reasons, otherwise we normally expect to be able to
determine output from a combination of source code, input, and knowledge of
the language.

Re: you think rust may outthrone c?

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

  copy mid

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

  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: Wed, 19 Jul 2023 15:12:57 -0700
Organization: None to speak of
Lines: 85
Message-ID: <87jzuvsg7q.fsf@nosuchdomain.example.com>
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>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="7cb07f2c0431ee5f8bb40869fb2e49a1";
logging-data="2466202"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/KuQwmlmnE002QYxUXfcGW"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:sodUknuGels25q9J4ZKz1/KMVKc=
sha1:+q65hY7c84g8R2Hr1rN0Jwe6MZE=
 by: Keith Thompson - Wed, 19 Jul 2023 22:12 UTC

David Brown <david.brown@hesbynett.no> writes:
[...]
> Virtually all current implementations use two's complement
> representation for signed integers. Up until C23, C allowed ones'
> complement and sign-magnitude as alternative representations - these
> are no long allowed in C23. However, integer types can still have
> padding bits in C23.
>
> I agree that it is reasonable to assume two's complement
> representation for signed integers, unless you are writing code with
> extreme portability.

Agreed, but I'm not entirely sure how it could be useful to write
code that assumes two's complement. In the vast majority of cases,
the code I'd write if I were assured that the implementation uses
two's complement and the code I'd write if I were told that the
target might use some other representation would be identical. A
signed integer type lets me store and manipulate integer values over
a specified range; I rarely care how those values are represented.
If I want to do bit manipulation, I'll use unsigned types.

I could certainly contrive some code that would behave differently
depending on how signed integers are represented, and I have no
doubt there are some cases where it makes sense to write such code
deliberately, but I think such code is rare.

> 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 applies only to the quick experiment I just did, and could vary
with the phase of the moon.)

The bottom line is that the "+" operator in that code does **not** mean
"apply the x86_64 addl instruction to the operands". It means "add the
operands in accordance with the semantics given in the C standard".

[...]

> The fact is that C++ compilers are C++ compilers, and C compilers are
> C compilers. They might share some common parts - I have never heard
> of a C++ compiler that did not have a companion C compiler, other than
> MSVC having an extremely limited companion C compiler. (I believe
> they finally implemented C99, some 20 years late.)

And I've never heard of a C and C++ compiler that share the same front
end. The C and C++ grammars have a lot of similarity, but it would be
insanely awkward to implement a single parser that can handle either
language.

[...]

--
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?

<a3781781-14c3-45be-8e5b-759c19fb456en@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:470e:b0:765:6a0f:8279 with SMTP id bs14-20020a05620a470e00b007656a0f8279mr2321qkb.0.1689805410292;
Wed, 19 Jul 2023 15:23:30 -0700 (PDT)
X-Received: by 2002:a05:6808:2025:b0:3a1:ef89:a49d with SMTP id
q37-20020a056808202500b003a1ef89a49dmr14209894oiw.2.1689805409996; Wed, 19
Jul 2023 15:23:29 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Wed, 19 Jul 2023 15:23:29 -0700 (PDT)
In-Reply-To: <87jzuvsg7q.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>
<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>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a3781781-14c3-45be-8e5b-759c19fb456en@googlegroups.com>
Subject: Re: you think rust may outthrone c?
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Wed, 19 Jul 2023 22:23:30 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 4814
 by: Malcolm McLean - Wed, 19 Jul 2023 22:23 UTC

On Wednesday, 19 July 2023 at 23:13:17 UTC+1, Keith Thompson wrote:
> David Brown <david...@hesbynett.no> writes:
> [...]
> > Virtually all current implementations use two's complement
> > representation for signed integers. Up until C23, C allowed ones'
> > complement and sign-magnitude as alternative representations - these
> > are no long allowed in C23. However, integer types can still have
> > padding bits in C23.
> >
> > I agree that it is reasonable to assume two's complement
> > representation for signed integers, unless you are writing code with
> > extreme portability.
>
> Agreed, but I'm not entirely sure how it could be useful to write
> code that assumes two's complement. In the vast majority of cases,
> the code I'd write if I were assured that the implementation uses
> two's complement and the code I'd write if I were told that the
> target might use some other representation would be identical. A
> signed integer type lets me store and manipulate integer values over
> a specified range; I rarely care how those values are represented.
> If I want to do bit manipulation, I'll use unsigned types.
>
> I could certainly contrive some code that would behave differently
> depending on how signed integers are represented, and I have no
> doubt there are some cases where it makes sense to write such code
> deliberately, but I think such code is rare.
>
> > 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
>
I get the output

-2147483648 <= 2147483647
Adnittedly I'm using a Mac and the command "gcc" actually invokes clang.

Re: you think rust may outthrone c?

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

  copy mid

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

  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: Wed, 19 Jul 2023 15:42:16 -0700
Organization: None to speak of
Lines: 34
Message-ID: <87fs5jseuv.fsf@nosuchdomain.example.com>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<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>
<87mszrsx6z.fsf@bsb.me.uk> <u99alq$292ke$1@dont-email.me>
<87wmyvr9kg.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="7cb07f2c0431ee5f8bb40869fb2e49a1";
logging-data="2474529"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX192X1Y2ZPOdwkxIk4jYThvb"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:USn6euReeogFdg/B0n6bzo6vYYw=
sha1:LHzq2QCWWkGC/dYwHLh7ynv3yp0=
 by: Keith Thompson - Wed, 19 Jul 2023 22:42 UTC

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.

[...]

--
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?

<20230719152940.570@kylheku.com>

  copy mid

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

  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: Wed, 19 Jul 2023 23:01:04 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 103
Message-ID: <20230719152940.570@kylheku.com>
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>
Injection-Date: Wed, 19 Jul 2023 23:01:04 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2ea12c6fbeb32cb78a2f4233d4a3c14b";
logging-data="2481181"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19s3BW0XJDOQcw34fjUqQoPxPsJ8lIJ9b8="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:wr06eT3HaxeS7sEUR3HE5je/Izg=
 by: Kaz Kylheku - Wed, 19 Jul 2023 23:01 UTC

On 2023-07-19, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
> David Brown <david.brown@hesbynett.no> writes:
> [...]
>> Virtually all current implementations use two's complement
>> representation for signed integers. Up until C23, C allowed ones'
>> complement and sign-magnitude as alternative representations - these
>> are no long allowed in C23. However, integer types can still have
>> padding bits in C23.
>>
>> I agree that it is reasonable to assume two's complement
>> representation for signed integers, unless you are writing code with
>> extreme portability.
>
> Agreed, but I'm not entirely sure how it could be useful to write
> code that assumes two's complement.

Here is one: most signed integers that appear in network packets
or files, and are not in textual decimal form, are in two's
complement.

If you assume your machine is two's complement, then the code
for decoding and encoding is simpler.

Under two's complement you can also assume that:

- value conversion between signed and unsigned of equal width preserves
the bits; e.g (uint32_t) int32 is a hardware-level noop.

- conversion from wider to narrower simply truncates; if the
value fits, it is preserved.

- widening conversion sign-extends.

Say we have a 24 bit PCM audio sample in an integer that is 32 or
more bits, like an unsigned long. To write it out as a 24 bit big
endian sample, assuming 8 bit bytes, we can just do this:

put_byte(stream, sample >> 16);
put_byte(stream, sample >> 8);
put_byte(stream, sample);

We know that a two's complement 32 bit value, if it fits into 24
bits, can just be truncated to the lower 24 bits, and we're done.

We also know that narrowing conversions truncate; like when
we call put_byte(stream, sample), when sample is converted to
(unsigned char), that implementation-defined conversion preserves the
least significant 8 bits.

To recover the value we might do:

(long) get_byte(stream) << 16 |
(long) get_byte(stream) << 8 |
get_byte(stream) << 8 |

Then we test for the sign bit, and sign extend:

if ((sample & 0x800000) != 0)
sample |= 0xFF000000;

That's bad because it assumes 32 bits. I think could do this without
assuming how wide long is, like this:

if ((sample & 0x800000) != 0)
sample |= -0x1000000L;

Or, express that constant as a left shift:

if ((sample & 0x800000) != 0)
sample |= (-1L << 24);

In these kinds of situations, assuming two's complement and
certain conversion semantics simplifies the code a bit, and
possibly makes it faster.

I mean, we could extract the value as an unsigned;
say we have a ulong typedef:

(ulong) get_byte(stream) << 16 |
(ulong) get_byte(stream) << 8 |
get_byte(stream) << 8 |

Then we know that our bottom 24 bits are either a positive
value (we are almost done) or a two's complement negative
value, where we take the two's complement to get the
additive inverse positive value, cast to the signed
type and negate it:

if ((usample & 0x8000000) != 0)
sample = - (long) ((usample ^ 0xFFFFFF) + 1)
else
sample = usample;

The code doesn't look bad, but it's more operations:
XOR, add 1, negate. Under the two's complement
assumption, we just OR in a sign extension mask
and we are done.

--
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?

<u99qru$2brfo$1@bluemanedhawk.eternal-september.org>

  copy mid

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

  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: Wed, 19 Jul 2023 19:16:14 -0400
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <u99qru$2brfo$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: base64
Injection-Date: Wed, 19 Jul 2023 23:16:14 -0000 (UTC)
Injection-Info: bluemanedhawk.eternal-september.org; posting-host="26941b9b8c4c98b3e5e08fc529aa9a93";
logging-data="2485752"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18jWvODcfmlBNdHXCAJnkq/JBFqTaQq4wY="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:A88yHvWhDgOY1Ck37MR2G1KIwf4=
Content-Language: en-US
In-Reply-To: <u991ot$27egh$2@dont-email.me>
 by: Blue-Maned_Hawk - Wed, 19 Jul 2023 23:16 UTC

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.
--
⚗︎ | /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?

<20230719160546.668@kylheku.com>

  copy mid

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

  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: Wed, 19 Jul 2023 23:31:00 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 73
Message-ID: <20230719160546.668@kylheku.com>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<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>
<87mszrsx6z.fsf@bsb.me.uk> <u99alq$292ke$1@dont-email.me>
<87wmyvr9kg.fsf@bsb.me.uk> <87fs5jseuv.fsf@nosuchdomain.example.com>
Injection-Date: Wed, 19 Jul 2023 23:31:00 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2ea12c6fbeb32cb78a2f4233d4a3c14b";
logging-data="2491712"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19AbP6XrNUcRLTOZZjkF0iPG2DXdk5PAQ0="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:6jlgl0kSY+Z6SqoN1Rrw8vK5y0A=
 by: Kaz Kylheku - Wed, 19 Jul 2023 23:31 UTC

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.

--
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?

<ec9ed717-8433-4a09-a35b-1ae6012d2268n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:5703:0:b0:403:f3f9:850d with SMTP id 3-20020ac85703000000b00403f3f9850dmr22637qtw.3.1689810212088;
Wed, 19 Jul 2023 16:43:32 -0700 (PDT)
X-Received: by 2002:a05:6870:768c:b0:1b0:2f63:4ff5 with SMTP id
dx12-20020a056870768c00b001b02f634ff5mr37036oab.1.1689810211768; Wed, 19 Jul
2023 16:43:31 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Wed, 19 Jul 2023 16:43:31 -0700 (PDT)
In-Reply-To: <20230719152940.570@kylheku.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>
<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> <20230719152940.570@kylheku.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ec9ed717-8433-4a09-a35b-1ae6012d2268n@googlegroups.com>
Subject: Re: you think rust may outthrone c?
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Wed, 19 Jul 2023 23:43:32 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2401
 by: Malcolm McLean - Wed, 19 Jul 2023 23:43 UTC

On Thursday, 20 July 2023 at 00:01:19 UTC+1, Kaz Kylheku wrote:
>
> Or, express that constant as a left shift:
>
> if ((sample & 0x800000) != 0)
> sample |= (-1L << 24);
>
I've got exactly that code in the Baby X resource compiler.
gcc is giving me a warning about it when I use the "-pedantic-errors" flag.
(Thanks to Keith Thompson for pointing out these problems in the code).

Re: you think rust may outthrone c?

<u9a0o1$2cl0s$2@dont-email.me>

  copy mid

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

  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: Wed, 19 Jul 2023 17:56:32 -0700
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <u9a0o1$2cl0s$2@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<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> <u92mms$12tmp$1@dont-email.me>
<5fbef78e-14f8-43c4-afaf-17fa5bad12bdn@googlegroups.com>
<u94don$1c1k4$1@dont-email.me> <u95eqh$1ipij$1@dont-email.me>
<u95f7s$1ioti$2@dont-email.me> <u95fct$1ioti$3@dont-email.me>
<878rbdv2zk.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 20 Jul 2023 00:56:33 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="548cb02f8621473374aa0fef010fdab5";
logging-data="2511900"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+uRrs2wXRi6XDV5+tIrBUoFhrzwRRiUzI="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:+/4ykIPW5rDyZRNgFJ/jw/SDqNw=
Content-Language: en-US
In-Reply-To: <878rbdv2zk.fsf@bsb.me.uk>
 by: Chris M. Thomasson - Thu, 20 Jul 2023 00:56 UTC

On 7/18/2023 5:05 AM, Ben Bacarisse wrote:
> "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
>
>> Fun times! Storing meta data in a pointer, then masking it off before we
>> actually use the pointer. Undefined behavior for sure, but can it work and
>> be used in highly beneficial ways, yup.
>
> This can be done without any undefined behaviour. It's not "portable"
> but that's not the same as UB.
>

I concur. Convert pointer to uintptr_t, (optional aside for a moment),
perform bit operations that change the value. Before any use (deference)
of this mutated pointer value we mask off any changes; convert it back
from uintptr_t to a pointer, and deference it if its not null. This
works well for some interesting algorithms. We can also artificially
offset memory and store a reference/version count in the pointer values
to get around the ABA problem. Its an interesting method, trick. We can
also use the reference count as an important part of atomic differential
reference counting. Many things...

Re: you think rust may outthrone c?

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

  copy mid

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

  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 02:08:48 +0100
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <87cz0nqti7.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> <87fs5jseuv.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="718a5a877a69dbd1318115baaef9d27f";
logging-data="2518702"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1915bq6yWk0nBbpUwAXYWPMRZr+M4F5mb8="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:WbngTXWSdXopSviUcXQoAp4rF9k=
sha1:qnOCBYF5npGX9SlocDc32NAtOTI=
X-BSB-Auth: 1.902f1ed633656ef44fad.20230720020848BST.87cz0nqti7.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 20 Jul 2023 01:08 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

> 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.

I know that indeterminacy is not defined by the bits, but I could not
find any normative text that could lead one to conclude that accessing
such an object is undefined from the indeterminacy itself. Where is it?

> 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.

Annex J is not normative text. And if we take Annex J as accurately
conveying the intent, then the actual case being discussed (an allocated
object with indeterminate representation) is, in fact, not undefined
behaviour! Is that what was intended?

--
Ben.

Re: you think rust may outthrone c?

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

  copy mid

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

  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: Wed, 19 Jul 2023 18:53:42 -0700
Organization: None to speak of
Lines: 115
Message-ID: <87bkg7s5zt.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>
<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>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="7cb07f2c0431ee5f8bb40869fb2e49a1";
logging-data="2651816"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18tGVj5XUCcWtRPo+4ysQY0"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:HqP73/Zs9rruIi9ikIjAzg5bi5E=
sha1:eRgL1zpCDaz+35SLkd2DLkda9Xw=
 by: Keith Thompson - Thu, 20 Jul 2023 01:53 UTC

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.

--
Keith Thompson (The_Othermt _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?

<u9as0n$2knb8$1@dont-email.me>

  copy mid

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

  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 10:41:59 +0200
Organization: A noiseless patient Spider
Lines: 120
Message-ID: <u9as0n$2knb8$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 08:41:59 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="fe114861671a8d33dd49743b3e7ee78d";
logging-data="2776424"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ppBgs4iSAn2KRJq++7SYjUBGaWbcZ4Y8="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:Hhg3HyMprem86+swNcqJfTNMe1I=
Content-Language: en-GB
In-Reply-To: <87jzuvsg7q.fsf@nosuchdomain.example.com>
 by: David Brown - Thu, 20 Jul 2023 08:41 UTC

On 20/07/2023 00:12, Keith Thompson wrote:
> David Brown <david.brown@hesbynett.no> writes:
> [...]
>> Virtually all current implementations use two's complement
>> representation for signed integers. Up until C23, C allowed ones'
>> complement and sign-magnitude as alternative representations - these
>> are no long allowed in C23. However, integer types can still have
>> padding bits in C23.
>>
>> I agree that it is reasonable to assume two's complement
>> representation for signed integers, unless you are writing code with
>> extreme portability.
>
> Agreed, but I'm not entirely sure how it could be useful to write
> code that assumes two's complement.

I said it was reasonable, not that it was useful!

> In the vast majority of cases,
> the code I'd write if I were assured that the implementation uses
> two's complement and the code I'd write if I were told that the
> target might use some other representation would be identical. A
> signed integer type lets me store and manipulate integer values over
> a specified range; I rarely care how those values are represented.

I think the one situation where it could be important is in connection
with external data. If you want to read or write a file, or send a
network packet, and the format of that file or packet requires two's
complement signed integers then it is definitely very convenient to be
able to assume that your integers are already in that format. Combine
it with an assumption (usually valid, and easily checked at
compile-time) that your unsigned char's are 8 bit, and it makes your
code very much simpler.

> If I want to do bit manipulation, I'll use unsigned types.
>

Agreed. Bit manipulation on signed types is just /wrong/ !

> I could certainly contrive some code that would behave differently
> depending on how signed integers are represented, and I have no
> doubt there are some cases where it makes sense to write such code
> deliberately, but I think such code is rare.
>
>> 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 applies only to the quick experiment I just did, and could vary
> with the phase of the moon.)
>
> The bottom line is that the "+" operator in that code does **not** mean
> "apply the x86_64 addl instruction to the operands". It means "add the
> operands in accordance with the semantics given in the C standard".
>

Exactly.

> [...]
>
>> The fact is that C++ compilers are C++ compilers, and C compilers are
>> C compilers. They might share some common parts - I have never heard
>> of a C++ compiler that did not have a companion C compiler, other than
>> MSVC having an extremely limited companion C compiler. (I believe
>> they finally implemented C99, some 20 years late.)
>
> And I've never heard of a C and C++ compiler that share the same front
> end. The C and C++ grammars have a lot of similarity, but it would be
> insanely awkward to implement a single parser that can handle either
> language.
>

I can't say if it (sharing a front-end for C and C++) is done or not - I
don't know the details of all toolchains! I think it is conceivable
that C could be parsed as a variation of a subset of C++, especially if
the compiler did not support all features of C. (There are many
embedded compilers that have outdated or limited support for standards.)
Maybe some of the slightly bizarre optional features added to later C
standards - such as making VLAs and complex numbers optional in C11 -
were requested by groups making common C and C++ front-ends? I have no
evidence or references here, it's merely a vague idea.

I think it is a more common for compilers to have different front-ends
for C and C++ (and perhaps other languages - gcc and llvm support many),
but share a common middle-end, then have back-ends that are language
independent and target-dependent.

But to be safe and general, I referred to "companion compilers" -
usually when you install a C++ compiler of any sort, you also get a C
compiler with the toolchain.

Re: you think rust may outthrone c?

<u9as55$2knb8$2@dont-email.me>

  copy mid

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

  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 10:44:21 +0200
Organization: A noiseless patient Spider
Lines: 72
Message-ID: <u9as55$2knb8$2@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>
<a3781781-14c3-45be-8e5b-759c19fb456en@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 08:44:22 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="fe114861671a8d33dd49743b3e7ee78d";
logging-data="2776424"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+S9xQ0TFP8usX3WdJimpZaXgwyGvUFnew="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:Py3zWG74/zEKCWef4nQMEzDF7M0=
Content-Language: en-GB
In-Reply-To: <a3781781-14c3-45be-8e5b-759c19fb456en@googlegroups.com>
 by: David Brown - Thu, 20 Jul 2023 08:44 UTC

On 20/07/2023 00:23, Malcolm McLean wrote:
> On Wednesday, 19 July 2023 at 23:13:17 UTC+1, Keith Thompson wrote:
>> David Brown <david...@hesbynett.no> writes:
>> [...]
>>> Virtually all current implementations use two's complement
>>> representation for signed integers. Up until C23, C allowed ones'
>>> complement and sign-magnitude as alternative representations - these
>>> are no long allowed in C23. However, integer types can still have
>>> padding bits in C23.
>>>
>>> I agree that it is reasonable to assume two's complement
>>> representation for signed integers, unless you are writing code with
>>> extreme portability.
>>
>> Agreed, but I'm not entirely sure how it could be useful to write
>> code that assumes two's complement. In the vast majority of cases,
>> the code I'd write if I were assured that the implementation uses
>> two's complement and the code I'd write if I were told that the
>> target might use some other representation would be identical. A
>> signed integer type lets me store and manipulate integer values over
>> a specified range; I rarely care how those values are represented.
>> If I want to do bit manipulation, I'll use unsigned types.
>>
>> I could certainly contrive some code that would behave differently
>> depending on how signed integers are represented, and I have no
>> doubt there are some cases where it makes sense to write such code
>> deliberately, but I think such code is rare.
>>
>>> 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
>>
> 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.

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.

Re: you think rust may outthrone c?

<b5f1c671-ed9c-4bc4-b899-552d71335037n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:394b:b0:765:a9f8:9591 with SMTP id qs11-20020a05620a394b00b00765a9f89591mr18630qkn.7.1689842767804;
Thu, 20 Jul 2023 01:46:07 -0700 (PDT)
X-Received: by 2002:a05:6870:d89c:b0:1ba:e6c9:7ad with SMTP id
dv28-20020a056870d89c00b001bae6c907admr1265989oab.7.1689842767436; Thu, 20
Jul 2023 01:46:07 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.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 01:46:07 -0700 (PDT)
In-Reply-To: <87bkg7s5zt.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>
<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>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b5f1c671-ed9c-4bc4-b899-552d71335037n@googlegroups.com>
Subject: Re: you think rust may outthrone c?
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Thu, 20 Jul 2023 08:46:07 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 6308
 by: Malcolm McLean - Thu, 20 Jul 2023 08:46 UTC

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:
> >> [...]
> >>> 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.
>
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.

Re: you think rust may outthrone c?

<u9aspr$2knb8$3@dont-email.me>

  copy mid

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

  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 10:55:23 +0200
Organization: A noiseless patient Spider
Lines: 68
Message-ID: <u9aspr$2knb8$3@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.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> <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>
<874jm0t41e.fsf@bsb.me.uk>
<6425092b-d2ab-40c7-af6d-b1c1e73ef1cbn@googlegroups.com>
<878rbbsw0o.fsf@bsb.me.uk>
<076c5a98-4eea-4cce-b0fc-7f1a6305fe94n@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 08:55:24 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="fe114861671a8d33dd49743b3e7ee78d";
logging-data="2776424"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18QmYim6YC9yhF/qXnOGGCUKvk1gwNNpJA="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:NBVPKzQcEXMSm0UiPkCcigFU5uQ=
In-Reply-To: <076c5a98-4eea-4cce-b0fc-7f1a6305fe94n@googlegroups.com>
Content-Language: en-GB
 by: David Brown - Thu, 20 Jul 2023 08:55 UTC

On 19/07/2023 23:54, Malcolm McLean wrote:
> On Wednesday, 19 July 2023 at 17:31:51 UTC+1, Ben Bacarisse wrote:
>> Malcolm McLean <malcolm.ar...@gmail.com> writes:
>>
>>> On Wednesday, 19 July 2023 at 14:38:36 UTC+1, Ben Bacarisse wrote:
>>>> Malcolm McLean <malcolm.ar...@gmail.com> writes:
>>>>

>>> It is a bit of an odd situation. If we write a program which branches
>>> if a char is negative, it will produce one output if we use the
>>> "signed chars" option and another if we use the "unsigned chars"
>>> option. So two executables with the same source and written in the
>>> same language produce different output.
>> Yes, but I am surprised you think that's odd. Maybe I think about the
>> meaning of programs in very different terms to you. In formal
>> semantics, there's no problem stating that there is more than one
>> possible output, and when being informal you just need to adjust the
>> words a bit. The "meaning" of this program:
>>
>> #include <stdio.h>
>>
>> int main(void) { printf("%u\n", -1u); }
>>
>> is "print the decimal representation of the largest unsigned int". It's
>> not "print 4294967295" or "print 65535" (or any of the other
>> possibilities).
>>
> The intention of the programmer might be to print the largest unsigned int,
> or it might be to print 65535. If it's the first, then it's a type of meta program,
> examining the characteristics of the program itself.

Ben has told you the meaning of the program. If the programmer intended
to write code to print 65535, then he/she did a rather poor job of it.

> And whilst it's possible that
> an option could toggle between 32 bit and 16 bit ints, it's unlikely, because
> you create too many problems for the linker.

It is an option for the m68k target for gcc. (Early 68000 processors
had 16-bit ALUs and datapaths, but 32-bit registers and support for
32-bit operations. Thus they handled 16-bit operations significantly
faster than 32-bit, but were future-compatible.) The AVR target for gcc
supports a flag for 8-bit ints, which is non-standard but can be very
useful for small AVR programs.

> On different machines the same
> program might have different results, but that's to be expected. If two machines
> have different floating point hardware, then you'd expect slightly different output
> from well-written programs, and it's posible to have radically different output
> from badly-written programs.
> On the other hand, consider this.
>
> int ch = fgetc(fp);
>
> /* quick hack, if we run out of input use commandline */
> if (ch == EOF)
> ch = argv[1][0];
>
> if (ch < 32)
> /* control character, process here */
>
> The quick hack has of course broken the code. Unless the "signed char" option
> is turned off. I do find this odd behaviour and difficult to accept.

You find it odd and difficult to accept that code which you call a
"quick hack" might be broken? Why not just write correct code and be happy?

Re: you think rust may outthrone c?

<u9atdr$2ku7m$1@dont-email.me>

  copy mid

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

  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 11:06:05 +0200
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <u9atdr$2ku7m$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>
<4d15ab3d-fc3e-40a4-9ea5-1ac0cd6b4847n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 20 Jul 2023 09:06:03 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="10031f0e81423a2c0e359bd216cbd3a1";
logging-data="2783478"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18tQlCjCfqn+pKeV0i0MPtmkDDyCZZJ3bA="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:VdQWlpepur/0XHe2qG83HL8EzIw=
Content-Language: de-DE
In-Reply-To: <4d15ab3d-fc3e-40a4-9ea5-1ac0cd6b4847n@googlegroups.com>
 by: Bonita Montero - Thu, 20 Jul 2023 09:06 UTC

Am 19.07.2023 um 18:17 schrieb fir:
> środa, 19 lipca 2023 o 18:08:12 UTC+2 Bonita Montero napisał(a):
>> 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++.
>
> i asked for rust somewhat becouse there are people who say it should detrone c though
> i recently found an opinion it uis rather to 'dethrone' c++, your favourite pony

It might dethrone both. It's recently begun to be incorporated into
the Linux kernel, and the Linux kernel unfortunately never had any
C++ code.

>
> so what with that you will bite that rust?

Re: you think rust may outthrone c?

<u9atg7$2kv4f$1@dont-email.me>

  copy mid

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

  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 11:07:18 +0200
Organization: A noiseless patient Spider
Lines: 98
Message-ID: <u9atg7$2kv4f$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>
<87mszrsx6z.fsf@bsb.me.uk> <u99alq$292ke$1@dont-email.me>
<87wmyvr9kg.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 20 Jul 2023 09:07:19 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="fe114861671a8d33dd49743b3e7ee78d";
logging-data="2784399"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19gbtfwwYsavbQ/7hMbd8plw3aVDd1EwQ0="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:qdAogBpdksSa17fy6x/+MQOobRc=
In-Reply-To: <87wmyvr9kg.fsf@bsb.me.uk>
Content-Language: en-GB
 by: David Brown - Thu, 20 Jul 2023 09:07 UTC

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):

"""
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.

>
> 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 could say it means "print any int value or do anything at all when
> int can have non-value representations" but the latter part trumps the
> former in formal terms.
>

Yes. "Print any int value" would be right for an unspecified value, but
not for an indeterminate value.

Re: you think rust may outthrone c?

<u9atgg$2ku7m$2@dont-email.me>

  copy mid

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

  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 11:07:30 +0200
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <u9atgg$2ku7m$2@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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 20 Jul 2023 09:07:28 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="10031f0e81423a2c0e359bd216cbd3a1";
logging-data="2783478"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19dm6I36F0ZgOovqEBbNxQUlxHpPOqpcns="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:qkZRPFMV8Iq05a2DmtmWW9jc2XI=
Content-Language: de-DE
In-Reply-To: <u99qru$2brfo$1@bluemanedhawk.eternal-september.org>
 by: Bonita Montero - Thu, 20 Jul 2023 09:07 UTC

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.

Re: you think rust may outthrone c?

<u9aunu$2l5mt$1@dont-email.me>

  copy mid

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

  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 11:28:29 +0200
Organization: A noiseless patient Spider
Lines: 151
Message-ID: <u9aunu$2l5mt$1@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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 20 Jul 2023 09:28:30 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="fe114861671a8d33dd49743b3e7ee78d";
logging-data="2791133"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18pw8uhUHcVXyTUPytKUlP31j7mkAiqQcU="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:JBG+9gZpr0QUsCCoF9y4zF11U0Q=
Content-Language: en-GB
In-Reply-To: <87bkg7s5zt.fsf@nosuchdomain.example.com>
 by: David Brown - Thu, 20 Jul 2023 09:28 UTC

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.
"""

I'm trying to find references to indicate that use of indeterminate
values is UB (and also what "use" means in this context). I see in
6.5.2.5p16 (this is in N2346, draft of C18) there is a note suggesting
that any use of an indeterminate value is UB, but I can't see it as
normative. It refers to Example 8 for compound literals (and note that
the variables involved are all locals) :

"""
16 Note that if an iteration statement were used instead of an explicit
goto and a labeled statement, the lifetime of the unnamed object would
be the body of the loop only, and on entry next time around p would have
an indeterminate value, which would result in undefined behavior.
"""

Other than that, an "indeterminate value" is either a trap or an
"unspecified value". Unspecified values can be used safely - they are
valid values of their type, even though you have no idea what the value
might be.

So it would seem to me that if your implementation does not have any
trap values for the type in question, using indeterminate
(uninitialised) values is only UB for local (automatic storage)
variables. (Note that _Bool's will have trap values on pretty much any
platform.)

Re: you think rust may outthrone c?

<u9aval$2l5mt$2@dont-email.me>

  copy mid

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

  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 11:38:29 +0200
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <u9aval$2l5mt$2@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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 20 Jul 2023 09:38:29 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="fe114861671a8d33dd49743b3e7ee78d";
logging-data="2791133"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+bakwMAgNvM0JwQPk201596X4eLmoJ/3k="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:qnP7Nc0w+2DFnr1/3Evjklz7OXI=
In-Reply-To: <87ilafr8e0.fsf@bsb.me.uk>
Content-Language: en-GB
 by: David Brown - Thu, 20 Jul 2023 09:38 UTC

On 19/07/2023 21: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. Indeed you'd need new
> operators if you wanted to handle more than one size of integer.

I haven't used BCPL, but Forth is very similar in this aspect. "+" adds
two words (16-bit integers by tradition, but 32-bit on some systems),
"F+" adds two floating point numbers, "D+" adds two double-precision
integers, etc. You can define whatever new operators you like.

>
> Years ago I sketch out a design for a "modern" BCPL where the width of
> objects could be stated. It was not very successful or I might have
> tried to implement it.
>
>> BCPL is before my time. But I think you are correct. C was intended to
>> have stronger typing than BCPL.
>
> You must be a youngster (for Usenet)! BCPL was still actively used for
> R&D in Cambridge in the 1980s. My UG dissertation (1982) used BCPL.

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.

>
> I really used to like BCPL (I've not used for a while so I might not get
> on with it anymore). It was surprisingly easy to use while remaining
> very close to the metal. I looked at it's modern successor MCPL a while
> back and I thought that looked interesting too.
>

Re: you think rust may outthrone c?

<u9avim$2l5mt$3@dont-email.me>

  copy mid

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

  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 11:42:46 +0200
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <u9avim$2l5mt$3@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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 20 Jul 2023 09:42:46 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="fe114861671a8d33dd49743b3e7ee78d";
logging-data="2791133"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18DVKCCmiPNZ3z+g93Bv/aDf2JKtUEWFnM="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:janM0UCRAaff7AgujGzto6RtR2g=
In-Reply-To: <u99i9b$2ac5l$1@dont-email.me>
Content-Language: en-GB
 by: David Brown - Thu, 20 Jul 2023 09:42 UTC

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).

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.
>
>

Re: you think rust may outthrone c?

<T9Z30xGjSH1vJiyoC@bongo-ra.co>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!paganini.bofh.team!not-for-mail
From: spi...@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 20 Jul 2023 09:51:25 -0000 (UTC)
Organization: To protect and to server
Message-ID: <T9Z30xGjSH1vJiyoC@bongo-ra.co>
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=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 20 Jul 2023 09:51:25 -0000 (UTC)
Injection-Info: paganini.bofh.team; logging-data="3503923"; posting-host="9H7U5kayiTdk7VIdYU44Rw.user.paganini.bofh.team"; mail-complaints-to="usenet@bofh.team"; posting-account="9dIQLXBM7WM9KzA+yjdR4A";
Cancel-Lock: sha256:x1H2/0tEXMSJeurrniEzzBsrGAtu8uCLhN0uy5LVFeM=
X-Notice: Filtered by postfilter v. 0.9.3
X-Organisation: Weyland-Yutani
X-Server-Commands: nowebcancel
 by: Spiros Bousbouras - Thu, 20 Jul 2023 09:51 UTC

On Thu, 20 Jul 2023 01:46:07 -0700 (PDT)
Malcolm McLean <malcolm.arthur.mclean@gmail.com> 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.

So I take it that the largest value you could get accessing a byte through
an unsigned char would be 255 rather than 511.

> 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?

<c3be3eba-d5cb-427d-a9e4-1a59d2c9fd5en@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:301:b0:3ff:1fac:a5dd with SMTP id q1-20020a05622a030100b003ff1faca5ddmr23249qtw.2.1689849384614;
Thu, 20 Jul 2023 03:36:24 -0700 (PDT)
X-Received: by 2002:a05:6808:2015:b0:3a1:a15b:ef9f with SMTP id
q21-20020a056808201500b003a1a15bef9fmr2296095oiw.0.1689849384407; Thu, 20 Jul
2023 03:36:24 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.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 03:36:24 -0700 (PDT)
In-Reply-To: <T9Z30xGjSH1vJiyoC@bongo-ra.co>
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>
<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>
<T9Z30xGjSH1vJiyoC@bongo-ra.co>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c3be3eba-d5cb-427d-a9e4-1a59d2c9fd5en@googlegroups.com>
Subject: Re: you think rust may outthrone c?
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Thu, 20 Jul 2023 10:36:24 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2961
 by: Malcolm McLean - Thu, 20 Jul 2023 10:36 UTC

On Thursday, 20 July 2023 at 10:51:39 UTC+1, Spiros Bousbouras wrote:
> On Thu, 20 Jul 2023 01:46:07 -0700 (PDT)
> Malcolm McLean <malcolm.ar...@gmail.com> 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.
> So I take it that the largest value you could get accessing a byte through
> an unsigned char would be 255 rather than 511.
>
Yes. The vast majority of the instructions worked on multiples of 8 bits, and ignored
the ninth bit. So CHAR_BIT was 8 and unsigned char went from 0-255. However
by using a spot of assembly you could access the ninth bit and squeeze a bit
of extra data in. The ninth bit was physically present. The idea was that you could
pass rgba buffers to the GPU and it had a bit of wiggle room to help its internal
calculations.


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

Pages:123456789101112131415161718192021222324252627282930313233343536373839
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor