Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

A computer scientist is someone who fixes things that aren't broken.


devel / comp.lang.c / Re: you think rust may *DE*throne 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?

<WRawM.202896$TPw2.151582@fx17.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer01.ams4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx17.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: you think rust may outthrone c?
Newsgroups: comp.lang.c
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com> <87h6pyqgnp.fsf@nosuchdomain.example.com> <u9cld3$2uof8$1@dont-email.me> <878rbaqch6.fsf@nosuchdomain.example.com> <u9dm6t$370v3$1@dont-email.me> <u9dv2c$38ir2$1@dont-email.me> <u9e7bp$3a1ug$1@dont-email.me> <u9h055$3s62g$7@dont-email.me> <87351foebi.fsf@bsb.me.uk> <86tttts1g2.fsf@linuxsc.com> <87351dm210.fsf@nosuchdomain.example.com> <789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com> <u9rcgd$1h7l5$1@dont-email.me>
Lines: 22
Message-ID: <WRawM.202896$TPw2.151582@fx17.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Wed, 26 Jul 2023 15:21:26 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Wed, 26 Jul 2023 15:21:26 GMT
X-Received-Bytes: 1848
 by: Scott Lurndal - Wed, 26 Jul 2023 15:21 UTC

Bart <bc@freeuk.com> writes:
>On 26/07/2023 15:41, Malcolm McLean wrote:
> > On Monday, 24 July 2023 at 22:29:52 UTC+1, Keith Thompson wrote:
> >>
> >> Do you see some concrete bad consequence of requiring two's
> >> complement?
> >>
> > It means that if future technology means that two's complement is
> > no longer the engineering choice for chip designers, then either C
> > compilers will have to lose their closeness to the metal or that standard
> > will have to be revised and current programs will break.
>
>Come on, just making 'int' 64 bits instead of 32 will already break half
>the programs out there!

Cite, please.

>Why do think it seems to have stuck at 32 bits?

Because there is no need to change it.

Re: you think rust may outthrone c?

<u9rnnv$1iftl$1@dont-email.me>

  copy mid

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

  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, 26 Jul 2023 19:13:19 +0100
Organization: A noiseless patient Spider
Lines: 83
Message-ID: <u9rnnv$1iftl$1@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<87h6pyqgnp.fsf@nosuchdomain.example.com> <u9cld3$2uof8$1@dont-email.me>
<878rbaqch6.fsf@nosuchdomain.example.com> <u9dm6t$370v3$1@dont-email.me>
<u9dv2c$38ir2$1@dont-email.me> <u9e7bp$3a1ug$1@dont-email.me>
<u9h055$3s62g$7@dont-email.me> <87351foebi.fsf@bsb.me.uk>
<86tttts1g2.fsf@linuxsc.com> <87351dm210.fsf@nosuchdomain.example.com>
<789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com>
<u9rcgd$1h7l5$1@dont-email.me> <WRawM.202896$TPw2.151582@fx17.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 26 Jul 2023 18:13:19 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b6e4a737f8478b06c277856aa7f36508";
logging-data="1654709"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18DUsDISARKobAtUBiaUmpmWlaoyL2ZC2Q="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:ysGP2k+e47U0Xx3T0MHGNleLomI=
In-Reply-To: <WRawM.202896$TPw2.151582@fx17.iad>
 by: Bart - Wed, 26 Jul 2023 18:13 UTC

On 26/07/2023 16:21, Scott Lurndal wrote:
> Bart <bc@freeuk.com> writes:
>> On 26/07/2023 15:41, Malcolm McLean wrote:
>>> On Monday, 24 July 2023 at 22:29:52 UTC+1, Keith Thompson wrote:
>>>>
>>>> Do you see some concrete bad consequence of requiring two's
>>>> complement?
>>>>
>>> It means that if future technology means that two's complement is
>>> no longer the engineering choice for chip designers, then either C
>>> compilers will have to lose their closeness to the metal or that
standard
>>> will have to be revised and current programs will break.
>>
>> Come on, just making 'int' 64 bits instead of 32 will already break half
>> the programs out there!
>
> Cite, please.

So, there is no software that you know of that relies on 'int' being 32
bits?

I deal a lot with APIs expressed as C headers, which I have to create
bindings for. There is a preponderance of int32 types there, which is
puzzling; why int32 in particular, given it all runs on 64-bit machines?

>> Why do think it seems to have stuck at 32 bits?
>
> Because there is no need to change it.
>

Who says? Changing it would have these advantages:

* 64-bit ints would kick the signed overflow can much further down the
road. 4 billion times further to be exact. Even unsigned overflows
would benefit, because no one really wants those either, despite many
here pretending that that kind of overflow is perfectly alright.

It is extraordinary how much software seems to have a built-in +/- 2
billion limit, when a +/- 9 billion billion limit is so easy. I wonder
how many are put off by needing to write `long long int` or 'int64_t`
everywhere, or maybe people don't consider this aspect at all, or are
just lazy.

(One interesting observation when you attempt to translate C code, is
that apart from the dominance of i32 types, so many functions and
variables are needlessly exported from a module, because people are
either too lazy to write 'static`, or are just ignorant.)

* There would be no 2-level integer type where:

* 1234 has type i32, but 1234LL is needed for i64 (with 1234L being
anyone's guess). So 1 << 35 will overflow.
* Some operations are done at 32 bits, some at 64 bits
* Casts are needed to force a 64-bit evaluation
* You have to choose between "%d %ld %lld" to print anything

With a 64-bit int, all integer literals - sorry, constants - would have
an i64 or (for 2**63+) u64 type.

* In the majority of cases, ints, doubles and object and function
pointers would all have the same width

* There'd be little need for those clock_t, time_t, offset_t and myriad
other types, since i64 has a big enough range for anything. Or at
least, they can all be defined on top of 'int'

* Enums and case labels could be bigger than i32 without it being
dependent on compiler extensions

That fact is that so much software simply uses 'int' without thinking,
that has all these limitations, that it would be a no-brainer to make it
64 bits and overcome them at a stroke.

Of course it's a bit late for current 64-bit platforms which have
already made the choice, and changing it now would be very difficult.

So C is stuck with a funny 32-bit primary integer type, when the world
has been 64 bits for a couple of decades. People new to the language
might well ask, why 32 bits and not 64, and if not 64, then why not 16?

Re: you think rust may outthrone c?

<WNdwM.224816$GMN3.36273@fx16.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx16.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: you think rust may outthrone c?
Newsgroups: comp.lang.c
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com> <878rbaqch6.fsf@nosuchdomain.example.com> <u9dm6t$370v3$1@dont-email.me> <u9dv2c$38ir2$1@dont-email.me> <u9e7bp$3a1ug$1@dont-email.me> <u9h055$3s62g$7@dont-email.me> <87351foebi.fsf@bsb.me.uk> <86tttts1g2.fsf@linuxsc.com> <87351dm210.fsf@nosuchdomain.example.com> <789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com> <u9rcgd$1h7l5$1@dont-email.me> <WRawM.202896$TPw2.151582@fx17.iad> <u9rnnv$1iftl$1@dont-email.me>
Lines: 54
Message-ID: <WNdwM.224816$GMN3.36273@fx16.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Wed, 26 Jul 2023 18:41:58 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Wed, 26 Jul 2023 18:41:58 GMT
X-Received-Bytes: 3050
 by: Scott Lurndal - Wed, 26 Jul 2023 18:41 UTC

Bart <bc@freeuk.com> writes:
>
>On 26/07/2023 16:21, Scott Lurndal wrote:
> > Bart <bc@freeuk.com> writes:
> >> On 26/07/2023 15:41, Malcolm McLean wrote:
> >>> On Monday, 24 July 2023 at 22:29:52 UTC+1, Keith Thompson wrote:
> >>>>
> >>>> Do you see some concrete bad consequence of requiring two's
> >>>> complement?
> >>>>
> >>> It means that if future technology means that two's complement is
> >>> no longer the engineering choice for chip designers, then either C
> >>> compilers will have to lose their closeness to the metal or that
>standard
> >>> will have to be revised and current programs will break.
> >>
> >> Come on, just making 'int' 64 bits instead of 32 will already break half
> >> the programs out there!
> >
> > Cite, please.
>
>So, there is no software that you know of that relies on 'int' being 32
>bits?

So, you don't have any supporting evidence for your assertion. Noted.

>
>I deal a lot with APIs expressed as C headers, which I have to create
>bindings for. There is a preponderance of int32 types there, which is
>puzzling; why int32 in particular, given it all runs on 64-bit machines?

I've never seen an 'int32' type in any C or C++ code I've worked
with (and it's in the millions of lines by now). int32_t, yes. uint32_t,
yes. Which are the proper types to use when the programmer needs
a type with the corresponding attributes (width, signedness, etc).

>
>
> >> Why do think it seems to have stuck at 32 bits?
> >
> > Because there is no need to change it.
> >
>
>Who says? Changing it would have these advantages:
>
>* 64-bit ints would kick the signed overflow can much further down the

I, personally, haven't experienced any issues with signed overflow;
primarily because I very seldom actually use 'int' types in C or C++
myself.

Granted, I mainly do systems programming, not financial programming,
but then I'd argue that C/C++ aren't designed as financial programming
languages in the first place - use the right tool for the job.

Re: you think rust may outthrone c?

<871qgujuhv.fsf@bsb.me.uk>

  copy mid

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

  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, 26 Jul 2023 21:19:40 +0100
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <871qgujuhv.fsf@bsb.me.uk>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u9e4bh$39ff2$1@dont-email.me> <u9e8so$3addm$1@dont-email.me>
<u9edc7$3bdu0$1@dont-email.me> <u9em5t$3d7sv$1@dont-email.me>
<875y6dne2u.fsf@nosuchdomain.example.com>
<u9evak$3eutv$1@dont-email.me>
<3ff53ffd-299b-4dc8-a503-cfd170ce3e03n@googlegroups.com>
<u9gbnu$3pc9g$1@dont-email.me> <u9h29k$3ssnr$1@dont-email.me>
<u9hob6$3vo3c$1@dont-email.me> <u9jig1$9lnb$2@dont-email.me>
<u9jm4i$a4dp$1@dont-email.me> <u9jqnf$ak1k$1@dont-email.me>
<u9juf1$avv8$1@dont-email.me> <u9lafa$j89a$1@dont-email.me>
<u9li0r$k6vn$1@dont-email.me> <87ila9laoa.fsf@bsb.me.uk>
<86cz0fs86n.fsf@linuxsc.com> <87pm4fqppe.fsf@nosuchdomain.example.com>
<ec9e4fb6-0241-42c3-b037-437d98f06787n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="b5cdfce93621456808a6ca99a8a551a4";
logging-data="1671226"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/XE7qlkvNwYXWvgJFB2logbqEWdS7J5+A="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:GpLUGBJSpVzu5P51gjxubngHfIA=
sha1:6u2Oz5nSpABOxLxp0/KA1c6UEsQ=
X-BSB-Auth: 1.a5b672f16ab30985d052.20230726211940BST.871qgujuhv.fsf@bsb.me.uk
 by: Ben Bacarisse - Wed, 26 Jul 2023 20:19 UTC

Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:

> On Wednesday, 26 July 2023 at 05:09:22 UTC+1, Keith Thompson wrote:
>> Tim Rentsch <tr.1...@z991.linuxsc.com> writes:
>> > Ben Bacarisse <ben.u...@bsb.me.uk> writes:
>> [...]
>> >> Yes, C++ calls them literals. But that site does use the same
>> >> terminology as the C standard when talking about C:
>> >>
>> >> https://en.cppreference.com/w/c/language/integer_constant
>> >>
>> >> I prefer C++'s usage, since "integer constant" can be so easily
>> >> confused for "integer constant expression".
>> >
>> > Using the same term for both suggests a false equivalence, and
>> > also is ahistorical. The two kinds of entities are fundamentally
>> > different: constants denote values, literals denote objects.
>> > Constants, like mathematical constants, always denote the same
>> > value; literals denote different objects at different times or
>> > places, even if the values used to produce a given literal are
>> > always the same, which they need not be. The distinctions are
>> > too important to gloss over by using a common term for both.
>> When you say that "literals denote objects", are you referring
>> specifically to the way C uses the terms "string literal" and "compound
>> literal"?
>>
>> I haven't done an exhaustive search, but every language other than C
>> whose documentation I've just checked (C++, Ada, Perl, Python, Go, Java)
>> calls 42 an integer literal and "foo" a string literal. C is a bit of
>> an outlier in callling 42 an integer constant.
>>
>> I suggest that the fact that C uses "constant" for tokens that refer to
>> values and "literal" (string or compound) for constructs that refer to
>> anonymous objects was an arbitrary choice, and the distinction you
>> mention is not nearly as fundamental as you suggest it is.
>>
>> I do prefer to use the term "integer constant" when discussing C, but
>> the phrase "integer literal" is (a) correct in most other languages and
>> (b) perfectly clear. It wouldn't occur to me that "integer literal"
>> implies something that refers to an object.
>>
> The word "literal" means "of letters". So in this case C has it right, the
> other languages have it wrong.

If you are going be so literal, you need to explain how "" (in C) is "of
letters". And, since you presumably consider "123" to be "of letters",
why calling 123 an "integer literal" would be wrong. Anyway, technical
uses of words like literal are almost always figurative!

--
Ben.

Re: Overflow and undefined behaviour

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

  copy mid

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

  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: Overflow and undefined behaviour
Date: Wed, 26 Jul 2023 21:55:53 +0100
Organization: A noiseless patient Spider
Lines: 70
Message-ID: <87v8e6ie92.fsf@bsb.me.uk>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<87o7k8rzh5.fsf@nosuchdomain.example.com>
<0fa83b40-26e6-427a-ba84-6cf8ac33172an@googlegroups.com>
<u98odb$25mj8$1@dont-email.me>
<87jzuvsg7q.fsf@nosuchdomain.example.com>
<u9cfmj$2trto$1@dont-email.me>
<87h6pyqgnp.fsf@nosuchdomain.example.com>
<u9cld3$2uof8$1@dont-email.me>
<878rbaqch6.fsf@nosuchdomain.example.com>
<u9dm6t$370v3$1@dont-email.me> <u9dv2c$38ir2$1@dont-email.me>
<u9e7bp$3a1ug$1@dont-email.me> <u9h055$3s62g$7@dont-email.me>
<87351foebi.fsf@bsb.me.uk> <u9jgmu$9i98$1@dont-email.me>
<87o7k2l4ge.fsf@bsb.me.uk> <u9m5rp$nbif$1@dont-email.me>
<87o7k0kbq5.fsf@bsb.me.uk> <u9o1ie$12n8g$1@dont-email.me>
<87cz0gj8wl.fsf@bsb.me.uk> <FCjhVZE6QDuhDC+2i@bongo-ra.co>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="b5cdfce93621456808a6ca99a8a551a4";
logging-data="1686763"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18JkU9Fl8Vwg2Tqx6aceekMwl7UwsLBbBM="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:EEMRl4x8Ix6CopGukjJzy/etLP4=
sha1:qdkvZdYUoT/bCUufksHSo9jCt9I=
X-BSB-Auth: 1.61df93138704106fe569.20230726215553BST.87v8e6ie92.fsf@bsb.me.uk
 by: Ben Bacarisse - Wed, 26 Jul 2023 20:55 UTC

Spiros Bousbouras <spibou@gmail.com> writes:

> On Tue, 25 Jul 2023 16:41:30 +0100
> Ben Bacarisse <ben.usenet@bsb.me.uk> wrote:
>> David Brown <david.brown@hesbynett.no> writes:
>
>> Maybe the problem is partly the words. For example, testing for
>> overflow at run time can be easier with a defined incorrect result.
>>
>> Another comes from the simplicity of defining the semantics of + (and -
>> and * and so on). Having a+b be the sum of a+b or "bottom" is messier
>> than having it be (a+b) mod 2^width. (It's not the usual mod, it's a
>> biased one, but that does not really complicate matters too much.)
>>
>> Finally, there are cases that just don't need much thought. In BCPL one
>> writes (wrote?)
>>
>> LET mid = (low + high) / 2
>>
>> and there's no need to worry about overflow.

Note this is, while not actually wrong (it's from real code), is
irrelevant as an example since all the quantities were being treated as
pointers.

> And in C one can write
> mid = low + (high-low)/2 ;
>
> and not worry about overflow either. I find the latter easier to reason
> about too.

That can overflow using signed ints. In truth it was a bad example
because BCPL pointer arithmetic is not really signed or unsigned -- it
just works. And in C one could use unsigned offsets and not worry about
overflow.

>> I used to hope that by the 21st century we'd all be using various high
>> level languages where programmers could declare sub-ranges with whatever
>> arithmetic and overflow semantics made sense for the application,
>> including unbounded integers is that's what was wanted. And along-side
>> those we'd have tools to help in verification of these type
>> restrictions.
>
> Doesn't Ada give you some of this ? You can certainly write code in Ada
> with a proof of correctness but it takes too much time so I don't think that
> people do it much in Ada either. But see
> https://www.adacore.com/academia/projects/ironsides-secure-dns-server .

Yes, it does. I've not used it in anger, so I don't know how helpful it
really is. I suspect the rigour is intimidating.

> Generally , writing a computer verifiable proof means writing out a huge
> number of annoying little details and on most occasions there is not enough
> incentive to do that , either in computer programming or mathematics.

Agreed. Part of my hope was that not only would this spread to other
languages, it would offer a degree of informality that would make is
more user-friendly. When I "reason" about code fragments, I often don't
want a formal proof; I just want some help with the symbology and some
of the checking.

> The
> only change I can see is if AIs become good enough to write such proofs
> and feed them to a non AI programme.

Interesting. I'd not thought of that. Generative AI might be very good
at filling in boilerplate details.

--
Ben.

Re: Overflow and undefined behaviour

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

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!rocksolid2!news.neodome.net!usenet.network!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: Overflow and undefined behaviour
Date: Wed, 26 Jul 2023 22:07:32 +0100
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <87msziidpn.fsf@bsb.me.uk>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u98odb$25mj8$1@dont-email.me>
<87jzuvsg7q.fsf@nosuchdomain.example.com>
<u9cfmj$2trto$1@dont-email.me>
<87h6pyqgnp.fsf@nosuchdomain.example.com>
<u9cld3$2uof8$1@dont-email.me>
<878rbaqch6.fsf@nosuchdomain.example.com>
<u9dm6t$370v3$1@dont-email.me> <u9dv2c$38ir2$1@dont-email.me>
<u9e7bp$3a1ug$1@dont-email.me> <u9h055$3s62g$7@dont-email.me>
<87351foebi.fsf@bsb.me.uk> <u9jgmu$9i98$1@dont-email.me>
<87o7k2l4ge.fsf@bsb.me.uk> <u9m5rp$nbif$1@dont-email.me>
<87o7k0kbq5.fsf@bsb.me.uk> <u9o1ie$12n8g$1@dont-email.me>
<87cz0gj8wl.fsf@bsb.me.uk> <FCjhVZE6QDuhDC+2i@bongo-ra.co>
<87y1j3lkdl.fsf@nosuchdomain.example.com>
<tkXtTHxPmeibIJVRa@bongo-ra.co>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="b5cdfce93621456808a6ca99a8a551a4";
logging-data="1689336"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19+e6JUh6eBlWwb6u/kqOVHl0wqKaXjtxs="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:QrElzVe0bIb8XyT9rpw6e6jGlFw=
sha1:FpNYmMYvjaxmIeGHWr1rzHe3zOE=
X-BSB-Auth: 1.7ca55b3f0edb9e2b14fa.20230726220732BST.87msziidpn.fsf@bsb.me.uk
 by: Ben Bacarisse - Wed, 26 Jul 2023 21:07 UTC

Spiros Bousbouras <spibou@gmail.com> writes:

> But perhaps someone can explain why in BCPL you can write
>
> LET mid = (low + high) / 2
>
> without "much thought".

Ah, it was a dreadful example. I copied it from an old binary search
program that I used to use as an example for the care needed when
writing C. But it's been so long I had forgotten the context and the
context is that mid, low and high are pointers. BCPL just adds the
bits. Whether a pointer ever compares < 0 (i.e. if has the bit pattern
of a negative integer) makes no difference to the result in some
implementation, but in others it might.

So it's a bad example, and some thought is certainly needed to be sure
it's OK.

--
Ben.

Re: you think rust may outthrone c?

<u9s1v2$1jhg7$1@dont-email.me>

  copy mid

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

  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, 26 Jul 2023 22:07:46 +0100
Organization: A noiseless patient Spider
Lines: 77
Message-ID: <u9s1v2$1jhg7$1@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<878rbaqch6.fsf@nosuchdomain.example.com> <u9dm6t$370v3$1@dont-email.me>
<u9dv2c$38ir2$1@dont-email.me> <u9e7bp$3a1ug$1@dont-email.me>
<u9h055$3s62g$7@dont-email.me> <87351foebi.fsf@bsb.me.uk>
<86tttts1g2.fsf@linuxsc.com> <87351dm210.fsf@nosuchdomain.example.com>
<789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com>
<u9rcgd$1h7l5$1@dont-email.me> <WRawM.202896$TPw2.151582@fx17.iad>
<u9rnnv$1iftl$1@dont-email.me> <WNdwM.224816$GMN3.36273@fx16.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 26 Jul 2023 21:07:46 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b6e4a737f8478b06c277856aa7f36508";
logging-data="1689095"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18S8LZ5NZmTmMgwonv6lSEf5swyXq7NO+s="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:RSrjIwSzXQl7MXGwA3VLCZ8hT1o=
In-Reply-To: <WNdwM.224816$GMN3.36273@fx16.iad>
 by: Bart - Wed, 26 Jul 2023 21:07 UTC

On 26/07/2023 19:41, Scott Lurndal wrote:
> Bart <bc@freeuk.com> writes:

#include <stdint.h>
typedef int32_t int32;

>> On 26/07/2023 16:21, Scott Lurndal wrote:
>>> Bart <bc@freeuk.com> writes:
>>>> On 26/07/2023 15:41, Malcolm McLean wrote:
>>>>> On Monday, 24 July 2023 at 22:29:52 UTC+1, Keith Thompson wrote:
>>>>>>
>>>>>> Do you see some concrete bad consequence of requiring two's
>>>>>> complement?
>>>>>>
>>>>> It means that if future technology means that two's complement is
>>>>> no longer the engineering choice for chip designers, then either C
>>>>> compilers will have to lose their closeness to the metal or that
>> standard
>>>>> will have to be revised and current programs will break.
>>>>
>>>> Come on, just making 'int' 64 bits instead of 32 will already
break half
>>>> the programs out there!
>>>
>>> Cite, please.
>>
>> So, there is no software that you know of that relies on 'int' being 32
>> bits?
>
> So, you don't have any supporting evidence for your assertion. Noted.

So, *your* assertion is that you could simpy make `int` 64 bits
overnight, and most software could just be recompiled and still work
perfectly. Noted.

>> I deal a lot with APIs expressed as C headers, which I have to create
>> bindings for. There is a preponderance of int32 types there, which is
>> puzzling; why int32 in particular, given it all runs on 64-bit machines?
>
> I've never seen an 'int32' type in any C or C++ code I've worked
> with (and it's in the millions of lines by now).

You haven't looked much then. I've seen ANY NUMBER of variations based
around the `int32` and `i32` styles, created using typedefs, mainly
because people can't stand the built-in denotations of C, or wanted
something more stable.

So if someone talks about C and 'int32' at the same time, it really is
not hard to infer what the hell is is they're talking about.

You're turning into as much as a pedantic as the other guys. Usenet
articles are not source code, they're usually in English.

But if you genuinely have not got a clue, I've put a suitable typedef
for you at the top. Just don't try and compile this post, becase if is
not valid C code.

Jesus. Or is the intention here just to wind me up? Because it's worked!

>> * 64-bit ints would kick the signed overflow can much further down the
>
> I, personally, haven't experienced any issues with signed overflow;>
primarily because I very seldom actually use 'int' types in C or C++
> myself.

OK. Think about /why/ you avoid using 'int' types, then think about
those who do, which is going to be in the millions. All of those, of any
range of skill and experience, will of course have carefully weighed the
pros and cons of their decisions, and will have factored in the possible
switch of `int` to a 64-bit type in the future.

(I'd be curious as to what actual types you use where the problems of
overflow vanish, but never mind, it's going to be just another
belittling remark.)

Re: Overflow and undefined behaviour

<u9s319$1jl6l$1@dont-email.me>

  copy mid

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

  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: Overflow and undefined behaviour
Date: Wed, 26 Jul 2023 22:26:01 +0100
Organization: A noiseless patient Spider
Lines: 69
Message-ID: <u9s319$1jl6l$1@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<87o7k8rzh5.fsf@nosuchdomain.example.com>
<0fa83b40-26e6-427a-ba84-6cf8ac33172an@googlegroups.com>
<u98odb$25mj8$1@dont-email.me> <87jzuvsg7q.fsf@nosuchdomain.example.com>
<u9cfmj$2trto$1@dont-email.me> <87h6pyqgnp.fsf@nosuchdomain.example.com>
<u9cld3$2uof8$1@dont-email.me> <878rbaqch6.fsf@nosuchdomain.example.com>
<u9dm6t$370v3$1@dont-email.me> <u9dv2c$38ir2$1@dont-email.me>
<u9e7bp$3a1ug$1@dont-email.me> <u9h055$3s62g$7@dont-email.me>
<87351foebi.fsf@bsb.me.uk> <u9jgmu$9i98$1@dont-email.me>
<87o7k2l4ge.fsf@bsb.me.uk> <u9m5rp$nbif$1@dont-email.me>
<87o7k0kbq5.fsf@bsb.me.uk> <u9o1ie$12n8g$1@dont-email.me>
<87cz0gj8wl.fsf@bsb.me.uk> <FCjhVZE6QDuhDC+2i@bongo-ra.co>
<87v8e6ie92.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 26 Jul 2023 21:26:01 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b6e4a737f8478b06c277856aa7f36508";
logging-data="1692885"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+hl4bWBEHKEry02Qv8oX9EJzTSyk6QLBM="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:V1+8qTWNeM3vNTWIoe4v6IVEOhY=
In-Reply-To: <87v8e6ie92.fsf@bsb.me.uk>
 by: Bart - Wed, 26 Jul 2023 21:26 UTC

On 26/07/2023 21:55, Ben Bacarisse wrote:
> Spiros Bousbouras <spibou@gmail.com> writes:
>
>> On Tue, 25 Jul 2023 16:41:30 +0100
>> Ben Bacarisse <ben.usenet@bsb.me.uk> wrote:
>>> David Brown <david.brown@hesbynett.no> writes:
>>
>>> Maybe the problem is partly the words. For example, testing for
>>> overflow at run time can be easier with a defined incorrect result.
>>>
>>> Another comes from the simplicity of defining the semantics of + (and -
>>> and * and so on). Having a+b be the sum of a+b or "bottom" is messier
>>> than having it be (a+b) mod 2^width. (It's not the usual mod, it's a
>>> biased one, but that does not really complicate matters too much.)
>>>
>>> Finally, there are cases that just don't need much thought. In
BCPL one
>>> writes (wrote?)
>>>
>>> LET mid = (low + high) / 2
>>>
>>> and there's no need to worry about overflow.
>
> Note this is, while not actually wrong (it's from real code), is
> irrelevant as an example since all the quantities were being treated as
> pointers.

Why can't pointer values overflow when added together?

>> And in C one can write
>> mid = low + (high-low)/2 ;
>>
>> and not worry about overflow either. I find the latter easier to reason
>> about too.
>
> That can overflow using signed ints. In truth it was a bad example
> because BCPL pointer arithmetic is not really signed or unsigned -- it
> just works. And in C one could use unsigned offsets and not worry about
> overflow.

I thought unsigned overflow in C was just well-defined in the language,
not that it was rendered impossible!

If I run this code:

#include <stdio.h>

int main(void) {
unsigned int low = 0xC0000000;
unsigned int high = 0xE0000000;
unsigned int mid = (low + high)/2;

printf("%X\n", mid);
}

I'd really expected `mid` here to have the value 0xD0000000, instead it
prints out 0x50000000.

So, that's nothing to worry about?

OK ....

BTW if I change the types to 'unsigned long long int` (phew, there's a
reason people write 'u64' for short!), then it magically gives the value
I expect. That's OK too when behaviour changes dramatically like that?

Nothing at all to do with overflow, because that's impossible of course...

Re: you think rust may outthrone c?

<877cqmqlhh.fsf@nosuchdomain.example.com>

  copy mid

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

  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, 26 Jul 2023 16:52:26 -0700
Organization: None to speak of
Lines: 39
Message-ID: <877cqmqlhh.fsf@nosuchdomain.example.com>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u9edc7$3bdu0$1@dont-email.me> <u9em5t$3d7sv$1@dont-email.me>
<875y6dne2u.fsf@nosuchdomain.example.com>
<u9evak$3eutv$1@dont-email.me>
<3ff53ffd-299b-4dc8-a503-cfd170ce3e03n@googlegroups.com>
<u9gbnu$3pc9g$1@dont-email.me> <u9h29k$3ssnr$1@dont-email.me>
<u9hob6$3vo3c$1@dont-email.me> <u9jig1$9lnb$2@dont-email.me>
<u9jm4i$a4dp$1@dont-email.me> <u9jqnf$ak1k$1@dont-email.me>
<u9juf1$avv8$1@dont-email.me> <u9lafa$j89a$1@dont-email.me>
<u9li0r$k6vn$1@dont-email.me> <87ila9laoa.fsf@bsb.me.uk>
<86cz0fs86n.fsf@linuxsc.com> <87pm4fqppe.fsf@nosuchdomain.example.com>
<ec9e4fb6-0241-42c3-b037-437d98f06787n@googlegroups.com>
<u9qrrr$1fdli$1@dont-email.me>
<9fed512c-0230-497f-9650-a70c825fe74an@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="f8957b03f6dc45951cee385c25f0e511";
logging-data="1722313"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX194Z1UJ5RK0pbBQqQWBcdrt"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:5Pa02Np/RpirpWB/ZzfJETLj6dg=
sha1:XrVR/i0ihzql7bLRg3G9M9N+BTs=
 by: Keith Thompson - Wed, 26 Jul 2023 23:52 UTC

Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
> On Wednesday, 26 July 2023 at 11:17:46 UTC+1, Bart wrote:
>> On 26/07/2023 08:21, Malcolm McLean wrote:
[...]
>> > The word "literal" means "of letters". So in this case C has it
>> > right, the other languages have it wrong.
>> Does it? I can't find that meaning anywhere.
>>
>> The main definition for the /noun/ literal is that it means a misprint,
>> or a wrong letter.
>>
> It's an unusual sense. Usually the word means "not figurative", as in
> "a literal velvet glove". But in the C standard, a "string literal" obviously
> means "a string composed of letters".

No, it very obviously does not.

> The stem "liter" means "letter",
> for the Latin "litera".

In non-technical English, "literal" is almost always an adjective,
meaning "non-figurative". There's also a meaning as a noun which is
fairly obscure (I wasn't aware of it until recently).

In programming, the noun "literal" very commonly refers to what C calls
a "constant", or to a "string literal". (You won't find that meaning in
most non-technical dictionaries.) The fact that it's a cognate of the
Latin word for "letter" is hardly relevant. Or would you argue that
"abc" is a literal and "123" isn't?

In common technical jargon, 123 is an integer literal, and that's the
standard-defined techical term for it in many languages. C calls
it an integer constant (and I therefore prefer to use that term
when discussing C).

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

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

  copy mid

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

  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, 27 Jul 2023 01:06:43 +0100
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <87bkfyi5f0.fsf@bsb.me.uk>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<87o7k8rzh5.fsf@nosuchdomain.example.com>
<0fa83b40-26e6-427a-ba84-6cf8ac33172an@googlegroups.com>
<u98odb$25mj8$1@dont-email.me>
<87jzuvsg7q.fsf@nosuchdomain.example.com>
<u9cfmj$2trto$1@dont-email.me>
<87h6pyqgnp.fsf@nosuchdomain.example.com>
<u9cld3$2uof8$1@dont-email.me>
<878rbaqch6.fsf@nosuchdomain.example.com>
<u9dm6t$370v3$1@dont-email.me> <u9dv2c$38ir2$1@dont-email.me>
<u9e7bp$3a1ug$1@dont-email.me> <u9h055$3s62g$7@dont-email.me>
<87351foebi.fsf@bsb.me.uk> <u9jgmu$9i98$1@dont-email.me>
<87o7k2l4ge.fsf@bsb.me.uk> <u9m5rp$nbif$1@dont-email.me>
<87o7k0kbq5.fsf@bsb.me.uk> <u9o1ie$12n8g$1@dont-email.me>
<87cz0gj8wl.fsf@bsb.me.uk> <u9otu5$15mpl$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="5a5e343133fc3f20981bd9b482679604";
logging-data="1724826"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/wZonO0XEnIYjj5e5gYYTuHIuLFGfAHc8="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:0IaTdiFnHBFYifvntjsGhnRDyn4=
sha1:jAnC1JoPiiPhTaRlqZtqtWskltM=
X-BSB-Auth: 1.1762203e168c9178bf57.20230727010643BST.87bkfyi5f0.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 27 Jul 2023 00:06 UTC

Bart <bc@freeuk.com> writes:

> On 25/07/2023 16:41, Ben Bacarisse wrote:
>> David Brown <david.brown@hesbynett.no> writes:
>>> If overflow is fully defined behaviour, then it is part of the language.
>>> It is now normal behaviour in normal code, not an indication of an
>>> error.
>>
>> a[i + 1] is an error if i is 2 and the array and only three elements.
>> You are privileging one small kind of error as one we might want help
>> finding.
>
> That's the kind of UB which is genuinely undefined, as the result can be
> unpredictable: it may return garbage, or may give a memory error if outside
> an allocation. (It could also be well-defined, IMV at least, if the
> 3-element array is in the middle of a struct or union.)

If you were any other poster I would say that I think the word
"behaviour" in "undefined behaviour" has led you to misunderstand the
term. But I can't figure out how, after all these years, you don't know
what the term means. Are you deliberately misusing it just to get
people to chat (AKA trolling) or do you really no know?

--
Ben.

Re: you think rust may outthrone c?

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

  copy mid

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

  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, 26 Jul 2023 17:08:04 -0700
Organization: None to speak of
Lines: 31
Message-ID: <87zg3ip66z.fsf@nosuchdomain.example.com>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<87edl6uf9y.fsf@bsb.me.uk> <u95rn3$1k9hq$1@dont-email.me>
<87r0p4tyx4.fsf@bsb.me.uk>
<c52e1506-b0a5-4e5b-99c0-5e79c5305a3an@googlegroups.com>
<87o7k8rzh5.fsf@nosuchdomain.example.com>
<0fa83b40-26e6-427a-ba84-6cf8ac33172an@googlegroups.com>
<u98odb$25mj8$1@dont-email.me>
<87jzuvsg7q.fsf@nosuchdomain.example.com>
<u9cfmj$2trto$1@dont-email.me>
<87h6pyqgnp.fsf@nosuchdomain.example.com>
<u9cld3$2uof8$1@dont-email.me>
<878rbaqch6.fsf@nosuchdomain.example.com>
<u9dm6t$370v3$1@dont-email.me> <u9dv2c$38ir2$1@dont-email.me>
<u9e7bp$3a1ug$1@dont-email.me> <u9h055$3s62g$7@dont-email.me>
<87351foebi.fsf@bsb.me.uk> <86tttts1g2.fsf@linuxsc.com>
<87351dm210.fsf@nosuchdomain.example.com>
<789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="f8957b03f6dc45951cee385c25f0e511";
logging-data="1728236"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX191GW8DL0nSCY8T9/V+UHqN"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:eJsvlLWyvSaVyh4Rwm8C/gao2gs=
sha1:1carxPg9RmbTZnC+JqjMilb3u7k=
 by: Keith Thompson - Thu, 27 Jul 2023 00:08 UTC

Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
> On Monday, 24 July 2023 at 22:29:52 UTC+1, Keith Thompson wrote:
>> Do you see some concrete bad consequence of requiring two's
>> complement?
>>
> It means that if future technology means that two's complement is
> no longer the engineering choice for chip designers, then either C
> compilers will have to lose their closeness to the metal or that standard
> will have to be revised and current programs will break.

That's hypothetical, not concrete.

I see this a similar to the change (in C99, I think?) that added
a guarantee that all-bits-zero is a valid representation of 0 for
any integer type. The change (slightly) simplified the language
and was possible because all implementations already satisified
the guarantee.

Or to the change in C99 that eliminated all signed integer
representations other than sign and magnitude, two's complement,
and ones' complement (though C90 had requirements might already
have implicitly precluded any other reprsentation).

Apparently the editors of the standard felt that it was unlikely that
any future hardware would use something other than two's-complement.
Do you have any reason to think they were mistaken?

--
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: Overflow and undefined behaviour

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

  copy mid

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

  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: Overflow and undefined behaviour
Date: Wed, 26 Jul 2023 17:26:48 -0700
Organization: None to speak of
Lines: 48
Message-ID: <87sf9ap5br.fsf@nosuchdomain.example.com>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u98odb$25mj8$1@dont-email.me>
<87jzuvsg7q.fsf@nosuchdomain.example.com>
<u9cfmj$2trto$1@dont-email.me>
<87h6pyqgnp.fsf@nosuchdomain.example.com>
<u9cld3$2uof8$1@dont-email.me>
<878rbaqch6.fsf@nosuchdomain.example.com>
<u9dm6t$370v3$1@dont-email.me> <u9dv2c$38ir2$1@dont-email.me>
<u9e7bp$3a1ug$1@dont-email.me> <u9h055$3s62g$7@dont-email.me>
<87351foebi.fsf@bsb.me.uk> <u9jgmu$9i98$1@dont-email.me>
<87o7k2l4ge.fsf@bsb.me.uk> <u9m5rp$nbif$1@dont-email.me>
<87o7k0kbq5.fsf@bsb.me.uk> <u9o1ie$12n8g$1@dont-email.me>
<87cz0gj8wl.fsf@bsb.me.uk> <FCjhVZE6QDuhDC+2i@bongo-ra.co>
<87v8e6ie92.fsf@bsb.me.uk> <u9s319$1jl6l$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="f8957b03f6dc45951cee385c25f0e511";
logging-data="1731090"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19PT6aQPeDDjare3kwuTd+9"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:sWpFL/++kNrEYxIQcea21XHPupU=
sha1:fBwI+8Ot6y/6w2e1O3GbIZ1qc94=
 by: Keith Thompson - Thu, 27 Jul 2023 00:26 UTC

Bart <bc@freeuk.com> writes:
[...]
> I thought unsigned overflow in C was just well-defined in the
> language, not that it was rendered impossible!

The way the C standard describes it is that unsigned operations cannot
overflow. Rather, if the mathematical result of an unsigned operation
is outside the range of the type, the result is reduced modulo MAX+1.

The actual wording is in N1570 6.2.5p9:

A computation involving unsigned operands can never overflow,
because a result that cannot be represented by the resulting
unsigned integer type is reduced modulo the number that is one
greater than the largest value that can be represented by the
resulting type.

The standard could equivalently have referred to this as "overflow" and
stated that the result of an unsigned overflow is well defined.

The fact that the standard chose one of two equivalent ways to describe
the same semantics is not, in my opinion, a big deal.

> If I run this code:
>
> #include <stdio.h>
>
> int main(void) {
> unsigned int low = 0xC0000000;
> unsigned int high = 0xE0000000;
> unsigned int mid = (low + high)/2;
>
> printf("%X\n", mid);
> }
>
> I'd really expected `mid` here to have the value 0xD0000000, instead
> it prints out 0x50000000.

If that's what you expected, (assuming 32-bit unsigned int), your
expectation was mistaken -- and it's based on an example that Ben
has already acknowledged was a bad one.

[...]

--
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: Overflow and undefined behaviour

<875y66i3yo.fsf@bsb.me.uk>

  copy mid

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

  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: Overflow and undefined behaviour
Date: Thu, 27 Jul 2023 01:38:07 +0100
Organization: A noiseless patient Spider
Lines: 80
Message-ID: <875y66i3yo.fsf@bsb.me.uk>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u98odb$25mj8$1@dont-email.me>
<87jzuvsg7q.fsf@nosuchdomain.example.com>
<u9cfmj$2trto$1@dont-email.me>
<87h6pyqgnp.fsf@nosuchdomain.example.com>
<u9cld3$2uof8$1@dont-email.me>
<878rbaqch6.fsf@nosuchdomain.example.com>
<u9dm6t$370v3$1@dont-email.me> <u9dv2c$38ir2$1@dont-email.me>
<u9e7bp$3a1ug$1@dont-email.me> <u9h055$3s62g$7@dont-email.me>
<87351foebi.fsf@bsb.me.uk> <u9jgmu$9i98$1@dont-email.me>
<87o7k2l4ge.fsf@bsb.me.uk> <u9m5rp$nbif$1@dont-email.me>
<87o7k0kbq5.fsf@bsb.me.uk> <u9o1ie$12n8g$1@dont-email.me>
<87cz0gj8wl.fsf@bsb.me.uk> <FCjhVZE6QDuhDC+2i@bongo-ra.co>
<87v8e6ie92.fsf@bsb.me.uk> <u9s319$1jl6l$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="5a5e343133fc3f20981bd9b482679604";
logging-data="1732456"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/tG2V34FfiB67Lxx4Fzq4bUo+X+svmVjQ="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:wVlrma/rfzs4dbu9bVjlDsq1Sc4=
sha1:UIgRD0dB2+8vFkZdRoWRtRAQDgc=
X-BSB-Auth: 1.49d223e129eebafac7d4.20230727013807BST.875y66i3yo.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 27 Jul 2023 00:38 UTC

Bart <bc@freeuk.com> writes:

> On 26/07/2023 21:55, Ben Bacarisse wrote:
>> Spiros Bousbouras <spibou@gmail.com> writes:
>>
>>> On Tue, 25 Jul 2023 16:41:30 +0100
>>> Ben Bacarisse <ben.usenet@bsb.me.uk> wrote:
>>>> David Brown <david.brown@hesbynett.no> writes:
>>>
>>>> Maybe the problem is partly the words. For example, testing for
>>>> overflow at run time can be easier with a defined incorrect result.
>>>>
>>>> Another comes from the simplicity of defining the semantics of + (and -
>>>> and * and so on). Having a+b be the sum of a+b or "bottom" is messier
>>>> than having it be (a+b) mod 2^width. (It's not the usual mod, it's a
>>>> biased one, but that does not really complicate matters too much.)
>>>>
>>>> Finally, there are cases that just don't need much thought. In BCPL
> one
>>>> writes (wrote?)
>>>>
>>>> LET mid = (low + high) / 2
>>>>
>>>> and there's no need to worry about overflow.
>>
>> Note this is, while not actually wrong (it's from real code), is
>> irrelevant as an example since all the quantities were being treated as
>> pointers.
>
> Why can't pointer values overflow when added together?

BCPL defines the bit pattern that results from adding them, dividing
etc. There's no overflow in that sense. The resulting address may not
make sense so you still have to take care. That's why it was crap
example.

>>> And in C one can write
>>> mid = low + (high-low)/2 ;
>>>
>>> and not worry about overflow either. I find the latter easier to reason
>>> about too.
>>
>> That can overflow using signed ints. In truth it was a bad example
>> because BCPL pointer arithmetic is not really signed or unsigned -- it
>> just works. And in C one could use unsigned offsets and not worry about
>> overflow.
>
> I thought unsigned overflow in C was just well-defined in the language, not
> that it was rendered impossible!

Yes, it's impossible in C. But that's C using the word very narrowly --
overflow is an exception condition that only happens with signed
arithmetic. But one could, in a conversation in the pub, say that
"unsigned arithmetic overflow is defined to wrap". (You could say that
here as well, because the sentence makes it pretty clear how the words
are bring used.)

> If I run this code:
>
> #include <stdio.h>
>
> int main(void) {
> unsigned int low = 0xC0000000;
> unsigned int high = 0xE0000000;
> unsigned int mid = (low + high)/2;
>
> printf("%X\n", mid);
> }
>
> I'd really expected `mid` here to have the value 0xD0000000, instead it
> prints out 0x50000000.
>
> So, that's nothing to worry about?

Overflow is nothing to worry about, by the values wrap (technically, the
result is reduced modulo UINT_MAX+1). With unsigned offsets, low +
(high-low)/2 is fine.

--
Ben.

Re: you think rust may outthrone c?

<20230726173449.19@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.chmurka.net!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 27 Jul 2023 00:47:48 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 54
Message-ID: <20230726173449.19@kylheku.com>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u9edc7$3bdu0$1@dont-email.me> <u9em5t$3d7sv$1@dont-email.me>
<875y6dne2u.fsf@nosuchdomain.example.com> <u9evak$3eutv$1@dont-email.me>
<3ff53ffd-299b-4dc8-a503-cfd170ce3e03n@googlegroups.com>
<u9gbnu$3pc9g$1@dont-email.me> <u9h29k$3ssnr$1@dont-email.me>
<u9hob6$3vo3c$1@dont-email.me> <u9jig1$9lnb$2@dont-email.me>
<u9jm4i$a4dp$1@dont-email.me> <u9jqnf$ak1k$1@dont-email.me>
<u9juf1$avv8$1@dont-email.me> <u9lafa$j89a$1@dont-email.me>
<u9li0r$k6vn$1@dont-email.me> <87ila9laoa.fsf@bsb.me.uk>
<86cz0fs86n.fsf@linuxsc.com> <87pm4fqppe.fsf@nosuchdomain.example.com>
<ec9e4fb6-0241-42c3-b037-437d98f06787n@googlegroups.com>
<u9qrrr$1fdli$1@dont-email.me>
<9fed512c-0230-497f-9650-a70c825fe74an@googlegroups.com>
<877cqmqlhh.fsf@nosuchdomain.example.com>
Injection-Date: Thu, 27 Jul 2023 00:47:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8b46a856f685959d89dbb9806175f5b3";
logging-data="1733942"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18SqpliTDzFqXYT/GaV6iWWsSxs2OqFunU="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:v60/5oekHJ9sWbceiuLDpGoL9po=
 by: Kaz Kylheku - Thu, 27 Jul 2023 00:47 UTC

On 2023-07-26, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
> Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
>> On Wednesday, 26 July 2023 at 11:17:46 UTC+1, Bart wrote:
>>> On 26/07/2023 08:21, Malcolm McLean wrote:
> [...]
>>> > The word "literal" means "of letters". So in this case C has it
>>> > right, the other languages have it wrong.
>>> Does it? I can't find that meaning anywhere.
>>>
>>> The main definition for the /noun/ literal is that it means a misprint,
>>> or a wrong letter.
>>>
>> It's an unusual sense. Usually the word means "not figurative", as in
>> "a literal velvet glove". But in the C standard, a "string literal" obviously
>> means "a string composed of letters".
>
> No, it very obviously does not.
>
>> The stem "liter" means "letter",
>> for the Latin "litera".
>
> In non-technical English, "literal" is almost always an adjective,
> meaning "non-figurative". There's also a meaning as a noun which is
> fairly obscure (I wasn't aware of it until recently).

In ordinary English, there is a process by which adjectives
are used as nouns.

This seems to happen quite a bit with "ible"/"able" adjectives, but
others too.

One way it happens is that in some context, a certain noun occurs
with a certain adjective, and that noun can be understood:

E.g. "deliverable goods" become "deliverables"; "perishable goods"
"perishables"; "dirigible balloon" becomes "dirigible"; "submersible
vessel" becomes "submersible"; "convertible roof car" becomes
"convertible"; people Hilary Clinton doesn't like become "deplorable".

Classes of thing are referred by adjectives: the rich, the poor,
the wretched.

Certain expressions: "The long and the short of it is ...",
"through thick and thin".

"I'm with stupid."

English-speaking computer scientists simply followed this process in
dropping the word "constant" from "literal constant".

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

<u9sf9o$1kual$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 27 Jul 2023 01:55:20 +0100
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <u9sf9o$1kual$1@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<87o7k8rzh5.fsf@nosuchdomain.example.com>
<0fa83b40-26e6-427a-ba84-6cf8ac33172an@googlegroups.com>
<u98odb$25mj8$1@dont-email.me> <87jzuvsg7q.fsf@nosuchdomain.example.com>
<u9cfmj$2trto$1@dont-email.me> <87h6pyqgnp.fsf@nosuchdomain.example.com>
<u9cld3$2uof8$1@dont-email.me> <878rbaqch6.fsf@nosuchdomain.example.com>
<u9dm6t$370v3$1@dont-email.me> <u9dv2c$38ir2$1@dont-email.me>
<u9e7bp$3a1ug$1@dont-email.me> <u9h055$3s62g$7@dont-email.me>
<87351foebi.fsf@bsb.me.uk> <u9jgmu$9i98$1@dont-email.me>
<87o7k2l4ge.fsf@bsb.me.uk> <u9m5rp$nbif$1@dont-email.me>
<87o7k0kbq5.fsf@bsb.me.uk> <u9o1ie$12n8g$1@dont-email.me>
<87cz0gj8wl.fsf@bsb.me.uk> <u9otu5$15mpl$1@dont-email.me>
<87bkfyi5f0.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 27 Jul 2023 00:55:20 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f6c6f94519e1a2521af762b44f8b9876";
logging-data="1734997"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+5HThyaJ/z7aoCEsLVrERgSY+fITygHqY="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:LwATAx95dw/MSDnOcMpDJmISvVY=
In-Reply-To: <87bkfyi5f0.fsf@bsb.me.uk>
 by: Bart - Thu, 27 Jul 2023 00:55 UTC

On 27/07/2023 01:06, Ben Bacarisse wrote:
> Bart <bc@freeuk.com> writes:
>
>> On 25/07/2023 16:41, Ben Bacarisse wrote:
>>> David Brown <david.brown@hesbynett.no> writes:
>>>> If overflow is fully defined behaviour, then it is part of the
language.
>>>> It is now normal behaviour in normal code, not an indication of an
>>>> error.
>>>
>>> a[i + 1] is an error if i is 2 and the array and only three elements.
>>> You are privileging one small kind of error as one we might want help
>>> finding.
>>
>> That's the kind of UB which is genuinely undefined, as the result can be
>> unpredictable: it may return garbage, or may give a memory error if
outside
>> an allocation. (It could also be well-defined, IMV at least, if the
>> 3-element array is in the middle of a struct or union.)
>
> If you were any other poster I would say that I think the word
> "behaviour" in "undefined behaviour" has led you to misunderstand the
> term. But I can't figure out how, after all these years, you don't know
> what the term means. Are you deliberately misusing it just to get
> people to chat (AKA trolling) or do you really no know?
>

I genuinely don't know what you're getting at here.

But I acknowledge I'm not a 'standards-head', as most here seem to be.
Is that now a prerequisite to giving an opinion here?

I use the language for practical reasons, and I think most people who
use it who have probably never delved into the standards document either.

But I also, because I've spent a LOT of time using alternates that I
have devised, like to look at it from a different perspective and with
less reverence that most.

As for trolling, people pretending they don't have a clue what is meant
by 'i32' or 'int32', or don't know what is meant by 'integer literal',
might fall better into that category.

To get back to my point, I will reassert that I think that:

*(int*)1234567

is what I would call 'undefined behaviour', since I couldn't tell you
what would happen if executed.

But evaluating:

INT_MAX+1

is NOT what I would call 'undefined behaviour'; whatever unexpected
things you might observe in such programs, is the deliberate intention
of the compiler. Since actual hardware UB on signed overflow is rare.

Re: you think rust may outthrone c?

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

  copy mid

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

  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, 26 Jul 2023 18:03:00 -0700
Organization: None to speak of
Lines: 28
Message-ID: <87o7jyp3nf.fsf@nosuchdomain.example.com>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u98odb$25mj8$1@dont-email.me>
<87jzuvsg7q.fsf@nosuchdomain.example.com>
<u9cfmj$2trto$1@dont-email.me>
<87h6pyqgnp.fsf@nosuchdomain.example.com>
<u9cld3$2uof8$1@dont-email.me>
<878rbaqch6.fsf@nosuchdomain.example.com>
<u9dm6t$370v3$1@dont-email.me> <u9dv2c$38ir2$1@dont-email.me>
<u9e7bp$3a1ug$1@dont-email.me> <u9h055$3s62g$7@dont-email.me>
<87351foebi.fsf@bsb.me.uk> <u9jgmu$9i98$1@dont-email.me>
<87o7k2l4ge.fsf@bsb.me.uk> <u9m5rp$nbif$1@dont-email.me>
<87o7k0kbq5.fsf@bsb.me.uk> <u9o1ie$12n8g$1@dont-email.me>
<87cz0gj8wl.fsf@bsb.me.uk> <u9otu5$15mpl$1@dont-email.me>
<87bkfyi5f0.fsf@bsb.me.uk> <u9sf9o$1kual$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="f8957b03f6dc45951cee385c25f0e511";
logging-data="1735577"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ORLOkH7JkKDeJ1BbAOQg1"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:UPrvldUju4gW0mc0FNEsDG545Bk=
sha1:uj88bD1vyqGapeY0JSibmA4sLU8=
 by: Keith Thompson - Thu, 27 Jul 2023 01:03 UTC

Bart <bc@freeuk.com> writes:
[...]
> To get back to my point, I will reassert that I think that:
>
> *(int*)1234567
>
> is what I would call 'undefined behaviour', since I couldn't tell you
> what would happen if executed.
>
> But evaluating:
>
> INT_MAX+1
>
> is NOT what I would call 'undefined behaviour'; whatever unexpected
> things you might observe in such programs, is the deliberate intention
> of the compiler. Since actual hardware UB on signed overflow is rare.

Would you consider using a term other than "undefined behavio[u]r" for
whatever it is you're referring to?

If not, is it because you're being intentionally difficult?

(These are both serious questions.)

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

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

  copy mid

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

  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, 27 Jul 2023 03:17:42 +0100
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <87wmymgks9.fsf@bsb.me.uk>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u98odb$25mj8$1@dont-email.me>
<87jzuvsg7q.fsf@nosuchdomain.example.com>
<u9cfmj$2trto$1@dont-email.me>
<87h6pyqgnp.fsf@nosuchdomain.example.com>
<u9cld3$2uof8$1@dont-email.me>
<878rbaqch6.fsf@nosuchdomain.example.com>
<u9dm6t$370v3$1@dont-email.me> <u9dv2c$38ir2$1@dont-email.me>
<u9e7bp$3a1ug$1@dont-email.me> <u9h055$3s62g$7@dont-email.me>
<87351foebi.fsf@bsb.me.uk> <u9jgmu$9i98$1@dont-email.me>
<87o7k2l4ge.fsf@bsb.me.uk> <u9m5rp$nbif$1@dont-email.me>
<87o7k0kbq5.fsf@bsb.me.uk> <u9o1ie$12n8g$1@dont-email.me>
<87cz0gj8wl.fsf@bsb.me.uk> <u9otu5$15mpl$1@dont-email.me>
<87bkfyi5f0.fsf@bsb.me.uk> <u9sf9o$1kual$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="5a5e343133fc3f20981bd9b482679604";
logging-data="1871807"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/bdsY3wzzqiwT9STs1Vtd9poYgd0iQnC0="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:tgw8IOjTXenx9pTDitpZHO5SOEY=
sha1:QNYw62E30+bU0oiIAx3lL9LkgWU=
X-BSB-Auth: 1.6b007792264a0e62ee11.20230727031742BST.87wmymgks9.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 27 Jul 2023 02:17 UTC

Bart <bc@freeuk.com> writes:

> On 27/07/2023 01:06, Ben Bacarisse wrote:
>> Bart <bc@freeuk.com> writes:
>>
>>> On 25/07/2023 16:41, Ben Bacarisse wrote:
>>>> David Brown <david.brown@hesbynett.no> writes:
>>>>> If overflow is fully defined behaviour, then it is part of the
> language.
>>>>> It is now normal behaviour in normal code, not an indication of an
>>>>> error.
>>>>
>>>> a[i + 1] is an error if i is 2 and the array and only three elements.
>>>> You are privileging one small kind of error as one we might want help
>>>> finding.
>>>
>>> That's the kind of UB which is genuinely undefined, as the result can be
>>> unpredictable: it may return garbage, or may give a memory error if
> outside
>>> an allocation. (It could also be well-defined, IMV at least, if the
>>> 3-element array is in the middle of a struct or union.)
>>
>> If you were any other poster I would say that I think the word
>> "behaviour" in "undefined behaviour" has led you to misunderstand the
>> term. But I can't figure out how, after all these years, you don't know
>> what the term means. Are you deliberately misusing it just to get
>> people to chat (AKA trolling) or do you really no know?
>
> I genuinely don't know what you're getting at here.

Do you know what undefined behaviour, in the context of the C language
means? It's not a trick question. I assumed you must know, but maybe
you don't.

> To get back to my point, I will reassert that I think that:
>
> *(int*)1234567
>
> is what I would call 'undefined behaviour', since I couldn't tell you what
> would happen if executed.

It would be absurd if the term depended on what you can tell about what
would happen. So you must know that this can't be what it means in the
context of the C language.

--
Ben.

Re: you think rust may outthrone c?

<20230726193154.98@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 27 Jul 2023 02:50:16 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 98
Message-ID: <20230726193154.98@kylheku.com>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<87r0p4tyx4.fsf@bsb.me.uk>
<c52e1506-b0a5-4e5b-99c0-5e79c5305a3an@googlegroups.com>
<87o7k8rzh5.fsf@nosuchdomain.example.com>
<0fa83b40-26e6-427a-ba84-6cf8ac33172an@googlegroups.com>
<u98odb$25mj8$1@dont-email.me> <87jzuvsg7q.fsf@nosuchdomain.example.com>
<u9cfmj$2trto$1@dont-email.me> <87h6pyqgnp.fsf@nosuchdomain.example.com>
<u9cld3$2uof8$1@dont-email.me> <878rbaqch6.fsf@nosuchdomain.example.com>
<u9dm6t$370v3$1@dont-email.me> <u9dv2c$38ir2$1@dont-email.me>
<u9e7bp$3a1ug$1@dont-email.me> <u9h055$3s62g$7@dont-email.me>
<87351foebi.fsf@bsb.me.uk> <u9jgmu$9i98$1@dont-email.me>
<87o7k2l4ge.fsf@bsb.me.uk> <u9m5rp$nbif$1@dont-email.me>
<87o7k0kbq5.fsf@bsb.me.uk> <u9o1ie$12n8g$1@dont-email.me>
<87cz0gj8wl.fsf@bsb.me.uk> <u9otu5$15mpl$1@dont-email.me>
Injection-Date: Thu, 27 Jul 2023 02:50:16 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8b46a856f685959d89dbb9806175f5b3";
logging-data="1879137"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19s6oEGjGeRm+v9iBmCFXOBExpIZ3m/B+8="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:qsBZgLW9kigE6q9G5vf8ZIBS8Ps=
 by: Kaz Kylheku - Thu, 27 Jul 2023 02:50 UTC

On 2023-07-25, Bart <bc@freeuk.com> wrote:
> On 25/07/2023 16:41, Ben Bacarisse wrote:
> > David Brown <david.brown@hesbynett.no> writes:
> >> If overflow is fully defined behaviour, then it is part of the language.
> >> It is now normal behaviour in normal code, not an indication of an
> >> error.
> >
> > a[i + 1] is an error if i is 2 and the array and only three elements.
> > You are privileging one small kind of error as one we might want help
> > finding.
>
> That's the kind of UB which is genuinely undefined, as the result can be
> unpredictable: it may return garbage, or may give a memory error if
> outside an allocation. (It could also be well-defined, IMV at least, if
> the 3-element array is in the middle of a struct or union.)

Undefined in the context of the C language means "ISO-C-undefined".

It refers to situations in C programs for which ISO C doesn't specify
requirements.

Negative defined categories have a diverse membership, and the members
don't necessarily have a lot in common.

Consider the set of non-bicycle entities. Among them are fish, as well
as communism.

Undefined behavior is like this.

When you say "genuinely undefined", you probably mean something like
behavior for which no requirements are given by anone: not ISO C,
not the compiler vendor, not the hardware, nobody.

Then we are not using the term "undefined" as "ISO-C-Undefined".

If you do that, you have to be clear: not defined according to whom?

If we include the header <unistd.h> and call a function
read(STDIN_FILENO, buf, sizeof buf), that is undefined behavior
(ISO-C-Undefined behavior). However, it is defined behavior according
to POSIX (POSIX-C-Defined-Behavior).

Would that be an example of "not genuinely undefined"?

> But any UB due to integer overflow would be largely caused by a compiler
> deliberately invoking a certain behaviour because the UB tag gives it
> the licence to do so.

ISO-C-Undefined-behavior on integer overflow is caused by exactly one
thing: ISO C not defining the behavior.

If Foo-C compiler behaves in some documented way on integer overflow, then
the behavior is ISO-C-Undefined, but Foo-C-Defined.

If the Foo-C compiler has no documentation about what happens on integer
overflow, but you have the source code and are able to reverse
engineer what happens, and it makes some consistent sense, and you write
a document about it, then that can be BartC-Foo-C-Defined-Behavior
(with respect to those versions of the code you studied).

Similarly if you don't have source, but can reverse engineer the
Foo-C executable.

In this reverse engineering role, your definition has limited authority.
You don't know whether every installation of that compiler claiming
to be a certain version really is the same as the deliverables you
are working with.

Anyway, if we pin down who it is who is providing the definition of
behavior, and what is their role in assuring it, it becomes very clear.

It's usually best to look for positive confirmation of defined behavior.
If we can't find it, then we can conclude that the behavior is
undefined (in the sense of not defined by anyone; perhaps what you
are calling "genuinely").

I'm doing such and such in my program. What is the basis in my belief
that it ought to work? If it's required by ISO C, then that's it.
What if it isn't? Maybe it's defined by the compiler, or host
environment (such as POSIX).

If it's not defined by the compiler, why is it working anyway? Maybe due
to the way I know the technology works, there is no possible way the
compiler can prevent it from working.

For instance, if I know that a compiler works with translation units
in complete isolation and performs no optimizataions in linking,
then it has no way of telling that I'm referring to the same object
using two different structure types in different translation units,
which happen to be binary compatible. So my definition of behavior
can come from belief in the argument that it's impossible for the
program to break. I document for future maintainers that the code
depends on that assumption.

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

<c3d85960-93a1-4269-a024-46a4fd38d0d4n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:114:b0:403:fe96:5779 with SMTP id u20-20020a05622a011400b00403fe965779mr12966qtw.5.1690428065789;
Wed, 26 Jul 2023 20:21:05 -0700 (PDT)
X-Received: by 2002:a05:6808:1404:b0:3a4:24bc:125f with SMTP id
w4-20020a056808140400b003a424bc125fmr3393735oiv.1.1690428065572; Wed, 26 Jul
2023 20:21:05 -0700 (PDT)
Path: i2pn2.org!rocksolid2!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, 26 Jul 2023 20:21:05 -0700 (PDT)
In-Reply-To: <871qgujuhv.fsf@bsb.me.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:dd30:b3b3:c3fe:88aa;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:dd30:b3b3:c3fe:88aa
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u9e4bh$39ff2$1@dont-email.me> <u9e8so$3addm$1@dont-email.me>
<u9edc7$3bdu0$1@dont-email.me> <u9em5t$3d7sv$1@dont-email.me>
<875y6dne2u.fsf@nosuchdomain.example.com> <u9evak$3eutv$1@dont-email.me>
<3ff53ffd-299b-4dc8-a503-cfd170ce3e03n@googlegroups.com> <u9gbnu$3pc9g$1@dont-email.me>
<u9h29k$3ssnr$1@dont-email.me> <u9hob6$3vo3c$1@dont-email.me>
<u9jig1$9lnb$2@dont-email.me> <u9jm4i$a4dp$1@dont-email.me>
<u9jqnf$ak1k$1@dont-email.me> <u9juf1$avv8$1@dont-email.me>
<u9lafa$j89a$1@dont-email.me> <u9li0r$k6vn$1@dont-email.me>
<87ila9laoa.fsf@bsb.me.uk> <86cz0fs86n.fsf@linuxsc.com> <87pm4fqppe.fsf@nosuchdomain.example.com>
<ec9e4fb6-0241-42c3-b037-437d98f06787n@googlegroups.com> <871qgujuhv.fsf@bsb.me.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c3d85960-93a1-4269-a024-46a4fd38d0d4n@googlegroups.com>
Subject: Re: you think rust may outthrone c?
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Thu, 27 Jul 2023 03:21:05 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 5740
 by: Malcolm McLean - Thu, 27 Jul 2023 03:21 UTC

On Wednesday, 26 July 2023 at 21:19:55 UTC+1, Ben Bacarisse wrote:
> Malcolm McLean <malcolm.ar...@gmail.com> writes:
>
> > On Wednesday, 26 July 2023 at 05:09:22 UTC+1, Keith Thompson wrote:
> >> Tim Rentsch <tr.1...@z991.linuxsc.com> writes:
> >> > Ben Bacarisse <ben.u...@bsb.me.uk> writes:
> >> [...]
> >> >> Yes, C++ calls them literals. But that site does use the same
> >> >> terminology as the C standard when talking about C:
> >> >>
> >> >> https://en.cppreference.com/w/c/language/integer_constant
> >> >>
> >> >> I prefer C++'s usage, since "integer constant" can be so easily
> >> >> confused for "integer constant expression".
> >> >
> >> > Using the same term for both suggests a false equivalence, and
> >> > also is ahistorical. The two kinds of entities are fundamentally
> >> > different: constants denote values, literals denote objects.
> >> > Constants, like mathematical constants, always denote the same
> >> > value; literals denote different objects at different times or
> >> > places, even if the values used to produce a given literal are
> >> > always the same, which they need not be. The distinctions are
> >> > too important to gloss over by using a common term for both.
> >> When you say that "literals denote objects", are you referring
> >> specifically to the way C uses the terms "string literal" and "compound
> >> literal"?
> >>
> >> I haven't done an exhaustive search, but every language other than C
> >> whose documentation I've just checked (C++, Ada, Perl, Python, Go, Java)
> >> calls 42 an integer literal and "foo" a string literal. C is a bit of
> >> an outlier in callling 42 an integer constant.
> >>
> >> I suggest that the fact that C uses "constant" for tokens that refer to
> >> values and "literal" (string or compound) for constructs that refer to
> >> anonymous objects was an arbitrary choice, and the distinction you
> >> mention is not nearly as fundamental as you suggest it is.
> >>
> >> I do prefer to use the term "integer constant" when discussing C, but
> >> the phrase "integer literal" is (a) correct in most other languages and
> >> (b) perfectly clear. It wouldn't occur to me that "integer literal"
> >> implies something that refers to an object.
> >>
> > The word "literal" means "of letters". So in this case C has it right, the
> > other languages have it wrong.
> If you are going be so literal, you need to explain how "" (in C) is "of
> letters". And, since you presumably consider "123" to be "of letters",
> why calling 123 an "integer literal" would be wrong. Anyway, technical
> uses of words like literal are almost always figurative!
>
C source is human-readable. So in a sense, everything in the source code
is "literal". So in the statement int x = 123; we can say that "123" is a "literal"
if we want. But only if we also accept that "int", "x" and "=" are also "literals".
Alos we'd have to say that in the statement char *filename = 0; filename is a
"literal" and has a "literal' value.
That's not particularly helpful.
So we can say that when we say "of letters", we don't mean the source,
but the executable. A string literal is a string (of letters, embedded in the
executable). int x = 123 will store that value 123 somewhere in the executable,
but not in a representation "of letters". The core language C doesn't understand
that 123 and "123" refer to the same value (of course the standard library does
have functions which make this conversion).
So char *str = "123"; is a string literal, int x = 123; is an integer constant, not
an "integer literal". In fact str is a "literal integer" (an integer composed of
letters), though the term isn't in common use.

But in this case, the C standard gets the accepted meaning of the word right.

Re: you think rust may outthrone c?

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

  copy mid

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

  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, 26 Jul 2023 21:49:37 -0700
Organization: None to speak of
Lines: 46
Message-ID: <87h6pqot5q.fsf@nosuchdomain.example.com>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u9edc7$3bdu0$1@dont-email.me> <u9em5t$3d7sv$1@dont-email.me>
<875y6dne2u.fsf@nosuchdomain.example.com>
<u9evak$3eutv$1@dont-email.me>
<3ff53ffd-299b-4dc8-a503-cfd170ce3e03n@googlegroups.com>
<u9gbnu$3pc9g$1@dont-email.me> <u9h29k$3ssnr$1@dont-email.me>
<u9hob6$3vo3c$1@dont-email.me> <u9jig1$9lnb$2@dont-email.me>
<u9jm4i$a4dp$1@dont-email.me> <u9jqnf$ak1k$1@dont-email.me>
<u9juf1$avv8$1@dont-email.me> <u9lafa$j89a$1@dont-email.me>
<u9li0r$k6vn$1@dont-email.me> <87ila9laoa.fsf@bsb.me.uk>
<86cz0fs86n.fsf@linuxsc.com> <87pm4fqppe.fsf@nosuchdomain.example.com>
<ec9e4fb6-0241-42c3-b037-437d98f06787n@googlegroups.com>
<871qgujuhv.fsf@bsb.me.uk>
<c3d85960-93a1-4269-a024-46a4fd38d0d4n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="f8957b03f6dc45951cee385c25f0e511";
logging-data="1898390"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX191EHZaVEv8+oa8eb4fbWPy"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:wViUGV6mcWwNQBvW3w/APo5QDKk=
sha1:6uOC4SVjp4Uf4tnYBVnfWMNN0Ck=
 by: Keith Thompson - Thu, 27 Jul 2023 04:49 UTC

Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
[...]
> C source is human-readable. So in a sense, everything in the source
> code is "literal". So in the statement int x = 123; we can say that
> "123" is a "literal" if we want. But only if we also accept that
> "int", "x" and "=" are also "literals". Alos we'd have to say that in
> the statement char *filename = 0; filename is a "literal" and has a
> "literal' value.
> That's not particularly helpful.

No argument with that last sentence.

> So we can say that when we say "of letters", we don't mean the source,
> but the executable. A string literal is a string (of letters, embedded
> in the executable). int x = 123 will store that value 123 somewhere in
> the executable, but not in a representation "of letters". The core
> language C doesn't understand that 123 and "123" refer to the same
> value (of course the standard library does have functions which make
> this conversion).
> So char *str = "123"; is a string literal, int x = 123; is an integer
> constant, not an "integer literal". In fact str is a "literal integer"
> (an integer composed of letters), though the term isn't in common use.
>
> But in this case, the C standard gets the accepted meaning of the word right.

What the what??

First off, C's use of the word "literal" has nothing to do with letters.
(Yes, I acknowledge that the English words are cognates.) C has two
kinds of literals: string literals and compound literals. Nothing else
in C is called a "literal" (though, as we've discussed to death, numeric
constants are commonly and informally called "literals" as well).

Second, I'm getting the impression that you're using the word
"letter" in some (deliberately?) misleading sense. In C, there are
26 uppercase letters and 26 lowercase letters; nothing else is a
"letter" as defined by the standard. (Read N1570 5.2.1 if you don't
believe me.) What you wrote above could only approach making sense
if you're using "letter" to refer to something else.

Are we going to have to add a "Malcolm-" prefix to every term you use?

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

<20230726212240.453@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 27 Jul 2023 05:50:04 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 113
Message-ID: <20230726212240.453@kylheku.com>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u9e4bh$39ff2$1@dont-email.me> <u9e8so$3addm$1@dont-email.me>
<u9edc7$3bdu0$1@dont-email.me> <u9em5t$3d7sv$1@dont-email.me>
<875y6dne2u.fsf@nosuchdomain.example.com> <u9evak$3eutv$1@dont-email.me>
<3ff53ffd-299b-4dc8-a503-cfd170ce3e03n@googlegroups.com>
<u9gbnu$3pc9g$1@dont-email.me> <u9h29k$3ssnr$1@dont-email.me>
<u9hob6$3vo3c$1@dont-email.me> <u9jig1$9lnb$2@dont-email.me>
<u9jm4i$a4dp$1@dont-email.me> <u9jqnf$ak1k$1@dont-email.me>
<u9juf1$avv8$1@dont-email.me> <u9lafa$j89a$1@dont-email.me>
<u9li0r$k6vn$1@dont-email.me> <87ila9laoa.fsf@bsb.me.uk>
<86cz0fs86n.fsf@linuxsc.com> <87pm4fqppe.fsf@nosuchdomain.example.com>
<ec9e4fb6-0241-42c3-b037-437d98f06787n@googlegroups.com>
<871qgujuhv.fsf@bsb.me.uk>
<c3d85960-93a1-4269-a024-46a4fd38d0d4n@googlegroups.com>
Injection-Date: Thu, 27 Jul 2023 05:50:04 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8b46a856f685959d89dbb9806175f5b3";
logging-data="1908386"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19YVpCE1JEppeEOTNdBBKCfq0y4HuxGnXU="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:lQgCVFe9XEl0zBU+2HNCoEaed3A=
 by: Kaz Kylheku - Thu, 27 Jul 2023 05:50 UTC

On 2023-07-27, Malcolm McLean <malcolm.arthur.mclean@gmail.com> wrote:
> On Wednesday, 26 July 2023 at 21:19:55 UTC+1, Ben Bacarisse wrote:
>> Malcolm McLean <malcolm.ar...@gmail.com> writes:
>> > The word "literal" means "of letters". So in this case C has it right, the
>> > other languages have it wrong.
>> If you are going be so literal, you need to explain how "" (in C) is "of
>> letters". And, since you presumably consider "123" to be "of letters",
>> why calling 123 an "integer literal" would be wrong. Anyway, technical
>> uses of words like literal are almost always figurative!
>>
> C source is human-readable. So in a sense, everything in the source code
> is "literal". So in the statement int x = 123; we can say that "123" is a "literal"
> if we want. But only if we also accept that "int", "x" and "=" are also "literals".
> Alos we'd have to say that in the statement char *filename = 0; filename is a
> "literal" and has a "literal' value.

A literal is a piece of the program text which specifies data that is available
to the program. If a piece of program text doesn't specify a datum that is
available to the program, it's almost certainly not a literal.

The Lisp family of languages, particularly traditional Lisps, any the
program syntax can be turned into a literal by making it the argument of
the quote operator (where the quote operator syntax appears in a context
where it is evaluated as an expression).

E.g (defun add (x y) (+ x y)) is the syntax for a function definition
in Common Lisp, but (quote (defun add (x y) (+ x y))) is not a function
definition at all; provides access to the literal data (defun add (x y)
(+ x y)), This can be written '(defun add (x y) (+ x y)).

In Common Lisp, and some other dialects, the behavior is undefined
if you modify a literal, e.g (rplacd '(a . b) 3). This is similar
to "ab"[1] = 3 in C being undefined behavior. It is self-modifying
code, since the literal is part of the program's image: a piece of
itself.

So, yes, if C had a quote feature, then x = 123 could be a literal.

To a C compiler, "x = 123" is just data; characters, then tokens, then
part of a syntax tree. It's not a literal to that compiler because it's
not a piece of the compiler image. C doesn't have a quote feature for
code, so "x = 123" is never turned into a literal in the compiled
program. It's translated into code in which there is no equal sign, and
possibly no x either.

We can see concretely in a Lisp what is a literal and what isn't.

We compile the top-level expression

(defun f (x)
(append '(1 2 3) x '(4 5 6)))

which, if executed, defines a function.

This is the TXR Lisp interactive listener of TXR 289.
Quit with :quit or Ctrl-D on an empty line. Ctrl-X ? for cheatsheet.
If unwanted side effects persist, discontinue imperative programming.
1> (compile-toplevel
'(defun f (x)
(append '(1 2 3) x '(4 5 6))))
#<sys:vm-desc: 8d28a70>
2> (disassemble *1)
data:
0: f
1: (1 2 3)
2: (4 5 6)
syms:
0: sys:rt-defun
1: append
code:
0: 8C000009 close t4 0 4 9 1 1 nil t2
1: 00000004
2: 00010001
3: 00000004
4: 00000002
5: 20030003 gcall t3 1 d1 t2 d2
6: 04010001
7: 04020002
8: 10000003 end t3
9: 20020002 gcall t2 0 d0 t4
10: 04000000
11: 00000004
12: 10000002 end t2
instruction count:
5
#<sys:vm-desc: 8d28a70>

In the compiled image (a "VM descriptor" object which we can disassemble) we
see there are three literal registers. There are three literals: f, (1 2 3)
and (4 5 6). Thewse are found in the original expression, but not everything
in the orginal expression is a literal. For instance the (append ...)
expression does not appear as a literal.

The reason the symbol f appears as a literal is that it is needed for
defining the function. The instruction gcall t2 0 d0 t4 calls sys:rt-defun
(entry 0 in the symbol table), passing it d0 (which holds f) and t4,
which holds the lexical closure object from the close instruction.

The f function is instruction words 4-8.

So, we can see that only those parts of the syntax become literals
which are required to be available that way, due to being quoted
somehow, explicitly or implicitly (as in the case of f).

The other parts of the function definition are semantically analyzed and turn
into a different representation; like (append ...) becomes a gcall t3 1 d1 t2
d2 instruction, from which the original code is not available as a literal;
the append symbol doesn't appear anywhere in the translated image.

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

<38a28d33-3a89-4905-b3f3-94ad7e27bd03n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:1a83:b0:3ff:21f1:95b with SMTP id s3-20020a05622a1a8300b003ff21f1095bmr12584qtc.6.1690448667094;
Thu, 27 Jul 2023 02:04:27 -0700 (PDT)
X-Received: by 2002:aca:1219:0:b0:3a4:1484:b3db with SMTP id
25-20020aca1219000000b003a41484b3dbmr4249214ois.5.1690448666635; Thu, 27 Jul
2023 02:04:26 -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, 27 Jul 2023 02:04:26 -0700 (PDT)
In-Reply-To: <87h6pqot5q.fsf@nosuchdomain.example.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:dd30:b3b3:c3fe:88aa;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:dd30:b3b3:c3fe:88aa
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u9edc7$3bdu0$1@dont-email.me> <u9em5t$3d7sv$1@dont-email.me>
<875y6dne2u.fsf@nosuchdomain.example.com> <u9evak$3eutv$1@dont-email.me>
<3ff53ffd-299b-4dc8-a503-cfd170ce3e03n@googlegroups.com> <u9gbnu$3pc9g$1@dont-email.me>
<u9h29k$3ssnr$1@dont-email.me> <u9hob6$3vo3c$1@dont-email.me>
<u9jig1$9lnb$2@dont-email.me> <u9jm4i$a4dp$1@dont-email.me>
<u9jqnf$ak1k$1@dont-email.me> <u9juf1$avv8$1@dont-email.me>
<u9lafa$j89a$1@dont-email.me> <u9li0r$k6vn$1@dont-email.me>
<87ila9laoa.fsf@bsb.me.uk> <86cz0fs86n.fsf@linuxsc.com> <87pm4fqppe.fsf@nosuchdomain.example.com>
<ec9e4fb6-0241-42c3-b037-437d98f06787n@googlegroups.com> <871qgujuhv.fsf@bsb.me.uk>
<c3d85960-93a1-4269-a024-46a4fd38d0d4n@googlegroups.com> <87h6pqot5q.fsf@nosuchdomain.example.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <38a28d33-3a89-4905-b3f3-94ad7e27bd03n@googlegroups.com>
Subject: Re: you think rust may outthrone c?
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Thu, 27 Jul 2023 09:04:27 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 4538
 by: Malcolm McLean - Thu, 27 Jul 2023 09:04 UTC

On Thursday, 27 July 2023 at 05:50:00 UTC+1, Keith Thompson wrote:
> Malcolm McLean <malcolm.ar...@gmail.com> writes:
> [...]
> > C source is human-readable. So in a sense, everything in the source
> > code is "literal". So in the statement int x = 123; we can say that
> > "123" is a "literal" if we want. But only if we also accept that
> > "int", "x" and "=" are also "literals". Alos we'd have to say that in
> > the statement char *filename = 0; filename is a "literal" and has a
> > "literal' value.
> > That's not particularly helpful.
> No argument with that last sentence.
> > So we can say that when we say "of letters", we don't mean the source,
> > but the executable. A string literal is a string (of letters, embedded
> > in the executable). int x = 123 will store that value 123 somewhere in
> > the executable, but not in a representation "of letters". The core
> > language C doesn't understand that 123 and "123" refer to the same
> > value (of course the standard library does have functions which make
> > this conversion).
> > So char *str = "123"; is a string literal, int x = 123; is an integer
> > constant, not an "integer literal". In fact str is a "literal integer"
> > (an integer composed of letters), though the term isn't in common use.
> >
> > But in this case, the C standard gets the accepted meaning of the word right.
> What the what??
>
> First off, C's use of the word "literal" has nothing to do with letters.
> (Yes, I acknowledge that the English words are cognates.) C has two
> kinds of literals: string literals and compound literals. Nothing else
> in C is called a "literal" (though, as we've discussed to death, numeric
> constants are commonly and informally called "literals" as well).
>
> Second, I'm getting the impression that you're using the word
> "letter" in some (deliberately?) misleading sense. In C, there are
> 26 uppercase letters and 26 lowercase letters; nothing else is a
> "letter" as defined by the standard. (Read N1570 5.2.1 if you don't
> believe me.) What you wrote above could only approach making sense
> if you're using "letter" to refer to something else.
>
> Are we going to have to add a "Malcolm-" prefix to every term you use?
>
You can argue that char *str = "123" is not a string of letters because digits
are not letters, and if you were using the term normally then that's what you
might mean. But I'm using "of letters" as a drop-in for "literal", to show you
that that's what it means. "Litera", Latin "letter" so "literal", "of letters".

Re: you think rust may outthrone c?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 27 Jul 2023 02:42:06 -0700
Organization: None to speak of
Lines: 56
Message-ID: <87cz0dpu6p.fsf@nosuchdomain.example.com>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<875y6dne2u.fsf@nosuchdomain.example.com>
<u9evak$3eutv$1@dont-email.me>
<3ff53ffd-299b-4dc8-a503-cfd170ce3e03n@googlegroups.com>
<u9gbnu$3pc9g$1@dont-email.me> <u9h29k$3ssnr$1@dont-email.me>
<u9hob6$3vo3c$1@dont-email.me> <u9jig1$9lnb$2@dont-email.me>
<u9jm4i$a4dp$1@dont-email.me> <u9jqnf$ak1k$1@dont-email.me>
<u9juf1$avv8$1@dont-email.me> <u9lafa$j89a$1@dont-email.me>
<u9li0r$k6vn$1@dont-email.me> <87ila9laoa.fsf@bsb.me.uk>
<86cz0fs86n.fsf@linuxsc.com> <87pm4fqppe.fsf@nosuchdomain.example.com>
<ec9e4fb6-0241-42c3-b037-437d98f06787n@googlegroups.com>
<871qgujuhv.fsf@bsb.me.uk>
<c3d85960-93a1-4269-a024-46a4fd38d0d4n@googlegroups.com>
<87h6pqot5q.fsf@nosuchdomain.example.com>
<38a28d33-3a89-4905-b3f3-94ad7e27bd03n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="f8957b03f6dc45951cee385c25f0e511";
logging-data="1953989"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18+tYs4QJYDFdKJBrMQVfsg"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:oJexxDOYcctW+j/IZwXtCwCWsnA=
sha1:okpKIVzsqTDYZXbady6WfZAD0r8=
 by: Keith Thompson - Thu, 27 Jul 2023 09:42 UTC

Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
> On Thursday, 27 July 2023 at 05:50:00 UTC+1, Keith Thompson wrote:
>> Malcolm McLean <malcolm.ar...@gmail.com> writes:
>> [...]
>> > C source is human-readable. So in a sense, everything in the source
>> > code is "literal". So in the statement int x = 123; we can say that
>> > "123" is a "literal" if we want. But only if we also accept that
>> > "int", "x" and "=" are also "literals". Alos we'd have to say that in
>> > the statement char *filename = 0; filename is a "literal" and has a
>> > "literal' value.
>> > That's not particularly helpful.
>> No argument with that last sentence.
>> > So we can say that when we say "of letters", we don't mean the source,
>> > but the executable. A string literal is a string (of letters, embedded
>> > in the executable). int x = 123 will store that value 123 somewhere in
>> > the executable, but not in a representation "of letters". The core
>> > language C doesn't understand that 123 and "123" refer to the same
>> > value (of course the standard library does have functions which make
>> > this conversion).
>> > So char *str = "123"; is a string literal, int x = 123; is an integer
>> > constant, not an "integer literal". In fact str is a "literal integer"
>> > (an integer composed of letters), though the term isn't in common use.
>> >
>> > But in this case, the C standard gets the accepted meaning of the word right.
>> What the what??
>>
>> First off, C's use of the word "literal" has nothing to do with letters.
>> (Yes, I acknowledge that the English words are cognates.) C has two
>> kinds of literals: string literals and compound literals. Nothing else
>> in C is called a "literal" (though, as we've discussed to death, numeric
>> constants are commonly and informally called "literals" as well).
>>
>> Second, I'm getting the impression that you're using the word
>> "letter" in some (deliberately?) misleading sense. In C, there are
>> 26 uppercase letters and 26 lowercase letters; nothing else is a
>> "letter" as defined by the standard. (Read N1570 5.2.1 if you don't
>> believe me.) What you wrote above could only approach making sense
>> if you're using "letter" to refer to something else.
>>
>> Are we going to have to add a "Malcolm-" prefix to every term you use?
>>
> You can argue that char *str = "123" is not a string of letters because digits
> are not letters, and if you were using the term normally then that's what you
> might mean. But I'm using "of letters" as a drop-in for "literal", to show you
> that that's what it means. "Litera", Latin "letter" so "literal", "of letters".

If you're not going to address anything I wrote, it would save time if
you just said so.

If you're trying to let me know something, you've failed. I'm ok with
that if you are.

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

<u9ti5a$1s1f1$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 27 Jul 2023 11:50:18 +0100
Organization: A noiseless patient Spider
Lines: 64
Message-ID: <u9ti5a$1s1f1$1@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u98odb$25mj8$1@dont-email.me> <87jzuvsg7q.fsf@nosuchdomain.example.com>
<u9cfmj$2trto$1@dont-email.me> <87h6pyqgnp.fsf@nosuchdomain.example.com>
<u9cld3$2uof8$1@dont-email.me> <878rbaqch6.fsf@nosuchdomain.example.com>
<u9dm6t$370v3$1@dont-email.me> <u9dv2c$38ir2$1@dont-email.me>
<u9e7bp$3a1ug$1@dont-email.me> <u9h055$3s62g$7@dont-email.me>
<87351foebi.fsf@bsb.me.uk> <u9jgmu$9i98$1@dont-email.me>
<87o7k2l4ge.fsf@bsb.me.uk> <u9m5rp$nbif$1@dont-email.me>
<87o7k0kbq5.fsf@bsb.me.uk> <u9o1ie$12n8g$1@dont-email.me>
<87cz0gj8wl.fsf@bsb.me.uk> <u9otu5$15mpl$1@dont-email.me>
<87bkfyi5f0.fsf@bsb.me.uk> <u9sf9o$1kual$1@dont-email.me>
<87wmymgks9.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 27 Jul 2023 10:50:18 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f6c6f94519e1a2521af762b44f8b9876";
logging-data="1967585"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19lLtXDkNdmJSCDiEZvNWnkA1NNnJAbuUQ="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:OS3usAFGw81VyWKVYAzaEpATo2Q=
In-Reply-To: <87wmymgks9.fsf@bsb.me.uk>
 by: Bart - Thu, 27 Jul 2023 10:50 UTC

On 27/07/2023 03:17, Ben Bacarisse wrote:
> Bart <bc@freeuk.com> writes:
>

>> I genuinely don't know what you're getting at here.
>
> Do you know what undefined behaviour, in the context of the C language
> means? It's not a trick question. I assumed you must know, but maybe
> you don't.

AIUI it means that C chooses not to define some behaviour. You can leave
it there, or you can be more critical (or pragmatic), and ask questions
about why something is UB rather than implementation-defined, or why it
is UB at all, since it could be for historical reasons that no longer
apply, or for very unusual machines.

Most here will just take what the C standard says at face value. But if
you're an implementer (and actually, I'm one too!) then you have to make
a decision about what to do about things the standard says is undefined.

One UB I know about very well is signed integer overflow, which I
normally implement as wrapping. Another might be strict aliasing, which
doesn't really affect how I generate code.

In both cases compilers may seize on UB to allow them to omit
instructions in an attempt to generate slightly faster code (even though
my experiment with -fwrapv showed UB-based to be slower!).

This now puts the onus on users to pay more heed to UB, and be aware of
gotchas where the code no longer does what might seem obvious, since a
compiler might do something unexpected. And now you have to refactor
your code to work around that possible behaviour of the compiler.

To me that is undesirable. (How about taking code that appears to do an
obvious thing, and ensuring that that's exactly what it does?)

BTW, by users, I also have in mind the many languages that use C as an
intermediate language. There, there might be a source language where
some feature that is UB in C, is well-defined, and where it is known to
be well-defined on the desired target.

However, in between the two you have to go through C! Now such UB is a
nuisance.

>> To get back to my point, I will reassert that I think that:
>>
>> *(int*)1234567
>>
>> is what I would call 'undefined behaviour', since I couldn't tell
you what
>> would happen if executed.
>
> It would be absurd if the term depended on what you can tell about what
> would happen.

Why is it absurd? Because I use actual observation and reasoning rather
than just decreeing within a standards document that something is UB
because it just is? /That's/ absurd!

(Is there a Rationale document explaining the reasons behind all the
UB's of C?)

Re: you think rust may outthrone c?

<u9tko8$1s9cs$1@dont-email.me>

  copy mid

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

  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, 27 Jul 2023 13:34:31 +0200
Organization: A noiseless patient Spider
Lines: 108
Message-ID: <u9tko8$1s9cs$1@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<878rbaqch6.fsf@nosuchdomain.example.com> <u9dm6t$370v3$1@dont-email.me>
<u9dv2c$38ir2$1@dont-email.me> <u9e7bp$3a1ug$1@dont-email.me>
<u9h055$3s62g$7@dont-email.me> <87351foebi.fsf@bsb.me.uk>
<86tttts1g2.fsf@linuxsc.com> <87351dm210.fsf@nosuchdomain.example.com>
<789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com>
<u9rcgd$1h7l5$1@dont-email.me> <WRawM.202896$TPw2.151582@fx17.iad>
<u9rnnv$1iftl$1@dont-email.me> <WNdwM.224816$GMN3.36273@fx16.iad>
<u9s1v2$1jhg7$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 27 Jul 2023 11:34:32 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a73b140d724915d3073e7cf4d4b344b4";
logging-data="1975708"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/xbnXH2xAGVgns6j/Me9x4LuzyFX6sbR0="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
Thunderbird/60.6.1
Cancel-Lock: sha1:KjkK9p77I9JDB5qUn+VQSzriIdI=
In-Reply-To: <u9s1v2$1jhg7$1@dont-email.me>
Content-Language: en-GB
 by: David Brown - Thu, 27 Jul 2023 11:34 UTC

On 26/07/2023 23:07, Bart wrote:
> On 26/07/2023 19:41, Scott Lurndal wrote:
> > Bart <bc@freeuk.com> writes:
>
> #include <stdint.h>
> typedef int32_t int32;
>
> >> On 26/07/2023 16:21, Scott Lurndal wrote:
> >>> Bart <bc@freeuk.com> writes:
> >>>> On 26/07/2023 15:41, Malcolm McLean wrote:
> >>>>> On Monday, 24 July 2023 at 22:29:52 UTC+1, Keith Thompson wrote:
> >>>>>>
> >>>>>> Do you see some concrete bad consequence of requiring two's
> >>>>>> complement?
> >>>>>>
> >>>>> It means that if future technology means that two's complement is
> >>>>> no longer the engineering choice for chip designers, then either C
> >>>>> compilers will have to lose their closeness to the metal or that
> >> standard
> >>>>> will have to be revised and current programs will break.
> >>>>
> >>>> Come on, just making 'int' 64 bits instead of 32 will already
> break half
> >>>> the programs out there!
> >>>
> >>> Cite, please.
> >>
> >> So, there is no software that you know of that relies on 'int' being 32
> >> bits?
> >
> > So, you don't have any supporting evidence for your assertion.  Noted.
>
> So, *your* assertion is that you could simpy make `int` 64 bits
> overnight, and most software could just be recompiled and still work
> perfectly. Noted.
>

/Your/ assertion was that half the existing programs would break if
"int" were 64 bits instead of the more common 32 bits. You have failed
to produce the slightest justification for that. It is irrelevant
whether Scott or anyone else knows of programs that might have issues
with such a change. And Scott did not in any way say that you were
wrong in your claim - he just noted that you are apparently unable to
justify it. (I, for one, have little idea if you are right or wrong
because I am not familiar with the vast majority of C code written. I
don't believe you know any better either - but we await your evidence.)

>
> >> I deal a lot with APIs expressed as C headers, which I have to create
> >> bindings for. There is a preponderance of int32 types there, which is
> >> puzzling; why int32 in particular, given it all runs on 64-bit
> machines?
> >
> > I've never seen an 'int32' type in any C or C++ code I've worked
> > with (and it's in the millions of lines by now).
>
> You haven't looked much then. I've seen ANY NUMBER of variations based
> around the `int32` and `i32` styles, created using typedefs, mainly
> because people can't stand the built-in denotations of C, or wanted
> something more stable.
>

I think most C programmers have come across variants and alternatives to
"int32_t" that have much the same meaning. But these alternatives
typically come from either:

1. Code with a history from before C99 and the <stdint.h> types.
2. Code written to work with pre-C99 toolchains.
3. Newer code referring to or using type 1 or 2 code.
4. Code that uses different names to distinguish types for different
purposes, perhaps using more advanced linters to check usage in a
stronger manner than C compilers typically support.

I have only ever heard of one person who actively chooses some variant
other than the <stdint.h> types such as int32_t from a free choice,
without any particular reason or justification other than that they
think the identifier "int32_t" is ugly. You can guess who that person is.

> >> * 64-bit ints would kick the signed overflow can much further down the

(I actually agree that there would have been many advantages to making
"int" 64-bit on 64-bit systems. But there would also have been a key
disadvantage - it would make it very inconvenient to get 16-bit and
32-bit types with standard C integer types.)

> >
> > I, personally, haven't experienced any issues with signed overflow;>
> primarily because I very seldom actually use 'int' types in C or C++
> > myself.
>
> OK. Think about /why/ you avoid using 'int' types, then think about
> those who do, which is going to be in the millions. All of those, of any
> range of skill and experience, will of course have carefully weighed the
> pros and cons of their decisions, and will have factored in the possible
> switch of `int` to a 64-bit type in the future.
>
> (I'd be curious as to what actual types you use where the problems of
> overflow vanish, but never mind, it's going to be just another
> belittling remark.)
>

I can't answer for Scott, but for me it could be int16_t, int32_t or
int64_t, depending on the context - I make sure I use appropriate types
for the calculations I need, balanced with the efficiency requirements
on the particular target.


devel / comp.lang.c / Re: you think rust may *DE*throne c?

Pages:123456789101112131415161718192021222324252627282930313233343536373839
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor