Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Nuclear war would really set back cable." -- Ted Turner


devel / comp.lang.c / Re: Static bounds checking (was Re: C23 (C2x) changes)

SubjectAuthor
* C23 (C2x) changesMehdi Amini
+* Re: C23 (C2x) changesDavid Brown
|`- Re: C23 (C2x) changesMehdi Amini
+* Re: C23 (C2x) changesJohn Bode
|+* Re: C23 (C2x) changesDavid Brown
||+* Re: C23 (C2x) changesBart
|||+- Re: C23 (C2x) changesScott Lurndal
|||+* Re: C23 (C2x) changesDavid Brown
||||+* Re: C23 (C2x) changesBart
|||||`* Re: C23 (C2x) changesDavid Brown
||||| `* Re: C23 (C2x) changesBart
|||||  +- Re: C23 (C2x) changesKeith Thompson
|||||  `* Re: C23 (C2x) changesDavid Brown
|||||   +* Re: C23 (C2x) changesBart
|||||   |+- Re: C23 (C2x) changesKeith Thompson
|||||   |`* Re: C23 (C2x) changesDavid Brown
|||||   | `* Re: C23 (C2x) changesBart
|||||   |  `* Re: C23 (C2x) changesDavid Brown
|||||   |   `- Re: C23 (C2x) changesBart
|||||   `* Re: C23 (C2x) changesIan Pilcher
|||||    `- Re: C23 (C2x) changesScott Lurndal
||||`* Re: C23 (C2x) changesBart
|||| +* Re: C23 (C2x) changesScott Lurndal
|||| |+- Re: C23 (C2x) changesLew Pitcher
|||| |`* Re: C23 (C2x) changesTim Rentsch
|||| | `- Re: C23 (C2x) changesBranimir Maksimovic
|||| `- Re: C23 (C2x) changesKeith Thompson
|||`* Re: C23 (C2x) changesManfred
||| +* Re: C23 (C2x) changesBen Bacarisse
||| |`* Re: C23 (C2x) changesManfred
||| | +- Re: C23 (C2x) changesantispam
||| | `* Re: C23 (C2x) changesTim Rentsch
||| |  `* Re: C23 (C2x) changesBranimir Maksimovic
||| |   `* Re: C23 (C2x) changesKeith Thompson
||| |    `* Re: C23 (C2x) changesBranimir Maksimovic
||| |     `* Re: C23 (C2x) changesKeith Thompson
||| |      `* Re: C23 (C2x) changesBranimir Maksimovic
||| |       `* Re: C23 (C2x) changesKeith Thompson
||| |        `* Re: C23 (C2x) changesBranimir Maksimovic
||| |         +* Re: C23 (C2x) changesKeith Thompson
||| |         |`- Re: C23 (C2x) changesBranimir Maksimovic
||| |         `* Re: C23 (C2x) changesDavid Brown
||| |          `* Re: C23 (C2x) changesBranimir Maksimovic
||| |           `* Re: C23 (C2x) changesKeith Thompson
||| |            +- Re: C23 (C2x) changesBranimir Maksimovic
||| |            `* Re: C23 (C2x) changesTim Rentsch
||| |             `- Re: C23 (C2x) changesBranimir Maksimovic
||| `- Re: C23 (C2x) changesBranimir Maksimovic
||`* Re: C23 (C2x) changesBart
|| `* Re: C23 (C2x) changesLew Pitcher
||  +- Re: C23 (C2x) changesBart
||  `* Re: C23 (C2x) changesLew Pitcher
||   `- Re: C23 (C2x) changesBart
|`* Re: C23 (C2x) changesFlorian Weimer
| +- Re: C23 (C2x) changesGuillaume
| `- Re: C23 (C2x) changesKeith Thompson
+* Re: C23 (C2x) changesWilliam Ahern
|`* Re: C23 (C2x) changesTim Rentsch
| `- Re: C23 (C2x) changesBranimir Maksimovic
+* Re: C23 (C2x) changesGuillaume
|`* Re: C23 (C2x) changesPhilipp Klaus Krause
| `* Re: C23 (C2x) changesKeith Thompson
|  +* Re: C23 (C2x) changesBart
|  |`- Re: C23 (C2x) changesThiago Adams
|  `- Re: C23 (C2x) changesGuillaume
+* Static bounds checking (was Re: C23 (C2x) changes)William Ahern
|+* Re: Static bounds checking (was Re: C23 (C2x) changes)David Brown
||`- Re: Static bounds checking (was Re: C23 (C2x) changes)Philipp Klaus Krause
|`* Re: Static bounds checking (was Re: C23 (C2x) changes)Branimir Maksimovic
| +* Re: Static bounds checking (was Re: C23 (C2x) changes)Philipp Klaus Krause
| |`* Re: Static bounds checking (was Re: C23 (C2x) changes)Branimir Maksimovic
| | `- Re: Static bounds checking (was Re: C23 (C2x) changes)Philipp Klaus Krause
| `* Re: Static bounds checking (was Re: C23 (C2x) changes)Bonita Montero
|  `* Re: Static bounds checking (was Re: C23 (C2x) changes)Branimir Maksimovic
|   +* Re: Static bounds checking (was Re: C23 (C2x) changes)Philipp Klaus Krause
|   |+- Re: Static bounds checking (was Re: C23 (C2x) changes)Branimir Maksimovic
|   |`- Re: Static bounds checking (was Re: C23 (C2x) changes)antispam
|   `* Re: Static bounds checking (was Re: C23 (C2x) changes)Bonita Montero
|    `* Re: Static bounds checking (was Re: C23 (C2x) changes)Branimir Maksimovic
|     +* Re: Static bounds checking (was Re: C23 (C2x) changes)Kaz Kylheku
|     |`- Re: Static bounds checking (was Re: C23 (C2x) changes)Branimir Maksimovic
|     `- Re: Static bounds checking (was Re: C23 (C2x) changes)Bonita Montero
+* Re: C23 (C2x) changesThiago Adams
|`* Re: C23 (C2x) changesKeith Thompson
| +- Re: C23 (C2x) changesDavid Brown
| +* Re: C23 (C2x) changesThiago Adams
| |`- Re: C23 (C2x) changesThiago Adams
| `- Re: C23 (C2x) changesMehdi Amini
`* Re: C23 (C2x) changesTim Rentsch
 +* Re: C23 (C2x) changesThiago Adams
 |`* Re: C23 (C2x) changesTim Rentsch
 | `- Re: C23 (C2x) changesDavid Brown
 +* Re: C23 (C2x) changesGuillaume
 |+* Re: C23 (C2x) changesDavid Brown
 ||`* Re: C23 (C2x) changesGuillaume
 || `* Re: C23 (C2x) changesDavid Brown
 ||  `* Re: C23 (C2x) changesThiago Adams
 ||   `- Re: C23 (C2x) changesThiago Adams
 |`- Re: C23 (C2x) changesTim Rentsch
 `* Re: C23 (C2x) changesBonita Montero
  `* Re: C23 (C2x) changesJim Jackson

Pages:12345
Re: C23 (C2x) changes

<XAJ2J.15551$YG4.7400@fx15.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx15.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: C23 (C2x) changes
Newsgroups: comp.lang.c
References: <si99fr$ma4$1@dont-email.me> <siaa3b$t76$1@dont-email.me> <siac7m$8r0$1@dont-email.me> <siahul$tb8$1@dont-email.me> <siao15$qbr$1@dont-email.me> <siaplj$r7d$1@dont-email.me> <siasoc$m4t$1@dont-email.me> <siaufp$mhq$1@dont-email.me> <sicvbp$m4m$1@dont-email.me> <sifnk0$nvi$1@dont-email.me>
Lines: 11
Message-ID: <XAJ2J.15551$YG4.7400@fx15.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Wed, 22 Sep 2021 17:19:51 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Wed, 22 Sep 2021 17:19:51 GMT
X-Received-Bytes: 1253
X-Original-Bytes: 1202
 by: Scott Lurndal - Wed, 22 Sep 2021 17:19 UTC

Ian Pilcher <arequipeno@gmail.com> writes:
>On 9/21/21 10:56, David Brown wrote:
>> What do you see as the practical uses of having wrapping in signed
>> integers?
>
>I haven't seen this mentioned, so ... after the fact overflow detection
>seems like a nice thing that we can't currently have.

ADD ORDER-QUANTITY TO CUSTOMER-TOTAL-ORDERS ON OVERFLOW PERFORM HANDLE-QTY-OVERFLOW.

Sometimes the task defines the choice of language.

Re: C23 (C2x) changes

<sifsig$1ojn$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!Smk/rEQ09ac3o4C3SZ0ZJg.user.46.165.242.75.POSTED!not-for-mail
From: mess...@bottle.org (Guillaume)
Newsgroups: comp.lang.c
Subject: Re: C23 (C2x) changes
Date: Wed, 22 Sep 2021 20:27:24 +0200
Organization: Aioe.org NNTP Server
Message-ID: <sifsig$1ojn$1@gioia.aioe.org>
References: <si99fr$ma4$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="57975"; posting-host="Smk/rEQ09ac3o4C3SZ0ZJg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: fr
 by: Guillaume - Wed, 22 Sep 2021 18:27 UTC

Le 20/09/2021 à 08:24, Mehdi Amini a écrit :
> Hi,
>
> It seems these are some of changes for C23(C2x) standard taken from
> draft documents:
>
> https://en.cppreference.com/w/c/23
> https://thephd.dev/c-the-improvements-june-september-virtual-c-meeting
>
> What do you think of changes ?

Dunno - not that impressive. Don't get me wrong, I prefer the
conservative approach of the C std committee to the approach of the C++
one, which yields monsters.

But this looks like relatively minor improvements to me.

What I would like to see in a new C revision:
- Modules;
- Tagged blocks/tagged loop constructs.

The tagged loop thing could look like this:

outer_loop: for (i = 0; i < n; i++)
{ for (j = 0; j < i; j++)
{
...
if (...)
break outer_loop;
}
}

That would be more elegant and easier to statically analyze than goto's.
The syntax could be different, it's just to show the point. In
particular, to avoid confusion with goto labels, it could instead be
something like:

for outer_loop (i = 0; i < n; i++)
....

As to modules, that could be taken from C++20(?) modules, although I
think those are not that great, but that's a start.

Re: C23 (C2x) changes

<sig3fm$91t$1@solani.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From: pkk...@spth.de (Philipp Klaus Krause)
Newsgroups: comp.lang.c
Subject: Re: C23 (C2x) changes
Date: Wed, 22 Sep 2021 22:25:25 +0200
Message-ID: <sig3fm$91t$1@solani.org>
References: <si99fr$ma4$1@dont-email.me> <sifsig$1ojn$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 22 Sep 2021 20:25:26 -0000 (UTC)
Injection-Info: solani.org;
logging-data="9277"; mail-complaints-to="abuse@news.solani.org"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
In-Reply-To: <sifsig$1ojn$1@gioia.aioe.org>
X-User-ID: eJwFwQkBwDAIA0BLDU8AObQD/xJ250rwhdFpvr4YXc6oiHaiw1ltUo2yY5Fvge/M1XvaEi4/DuUQYA==
Cancel-Lock: sha1:Iv0fPtoarKxWweLz5S3EykwDpmI=
Content-Language: en-US
 by: Philipp Klaus Krause - Wed, 22 Sep 2021 20:25 UTC

Am 22.09.21 um 20:27 schrieb Guillaume:

> - Tagged blocks/tagged loop constructs.
>
>[…]
>
> That would be more elegant and easier to statically analyze than goto's.

No. It would not be better than goto. Neither for users nor for static
analysis. AFAIK this has been proposed and rejected multiple times
before (e.g. N1989 at the London 2016 WG14 meeting).

Regarding analysis (and likely also code readability), one important
parameter is the tree-width of the control-flow graph. For C this is
bounded by a constant plus the number of labels for goto used per
function. The situation is similar for many other languages. And at
least for tree-width, it has been proven that unlimited use of labeled
break / labeled continue, like Java has, would be just as bad as
unlimited use of goto.

If you need to get out of an inner loop, just use goto. Avoiding goto by
introducing another variant of goto that just isn't called goto won't
make the standard better.

Re: C23 (C2x) changes

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

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: C23 (C2x) changes
Date: Wed, 22 Sep 2021 14:05:18 -0700
Organization: None to speak of
Lines: 91
Message-ID: <87mto4micx.fsf@nosuchdomain.example.com>
References: <si99fr$ma4$1@dont-email.me> <sifsig$1ojn$1@gioia.aioe.org>
<sig3fm$91t$1@solani.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="b5fd9637bf49c8f43a3bd672d60f3caf";
logging-data="1329"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/TJEBxHBz0pr4RPdb53ysb"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:qH8pBVneJ/GD8BHg8yICIWevnyM=
sha1:920eLicnWXnlPjOE5MssEM8uimU=
 by: Keith Thompson - Wed, 22 Sep 2021 21:05 UTC

Philipp Klaus Krause <pkk@spth.de> writes:
> Am 22.09.21 um 20:27 schrieb Guillaume:
>
>> - Tagged blocks/tagged loop constructs.
>>
>>[…]
>>
>> That would be more elegant and easier to statically analyze than goto's.
>
> No. It would not be better than goto. Neither for users nor for static
> analysis. AFAIK this has been proposed and rejected multiple times
> before (e.g. N1989 at the London 2016 WG14 meeting).
>
> Regarding analysis (and likely also code readability), one important
> parameter is the tree-width of the control-flow graph. For C this is
> bounded by a constant plus the number of labels for goto used per
> function. The situation is similar for many other languages. And at
> least for tree-width, it has been proven that unlimited use of labeled
> break / labeled continue, like Java has, would be just as bad as
> unlimited use of goto.
>
> If you need to get out of an inner loop, just use goto. Avoiding goto by
> introducing another variant of goto that just isn't called goto won't
> make the standard better.

The proposal in N1989
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1989.htm
was to have "break 2;" break out of two enclosing loops. (The Bourne
shell has this feature.) Personally, I dislike this. It's easy to
forget to update the number when the code is rearranged, and it forces
the programmer and reader to count nesting levels -- and counting, after
all, is something that computers are really really good at.

What I'd like to see is *named* loops, with "break" and "continue"
optionally taking an argument that names the loop to be operated on.
I've used other languages with this feature, and I've found it quite
useful.

It would, of course, be equivalent to a goto targeting a point after the
end of the loop ("continue" might be a little more complicated), but the
point is that it's restricted ("break foo" can't jump to an arbitrary
location) and it documents what it's doing.

I think of "break foo" as an operation on the loop named "foo", not an
operation that refers to a specific location in the code.

It would make no difference to static analysis, but in my opinion it
would make for more legible code in the (perhaps not very common) case
where you want to break out of nested loops.

Ada has this feature. It uses a deliberately heavy syntax for goto
labels:

<< LABEL >>
-- ...
goto LABEL;

but a simple identifier followed by a colon for labeled loops:

Loop_Name:
for I in 1..10 loop
-- ...
exit Loop_Name; -- Ada spells "break" as "exit"
end loop;

Perl uses the same syntax for goto labels and loop names, which means if
you see a loop name you can't be sure without checking that there isn't
a goto somewhere that targets it. I haven't found that to be a problem
in practice:

Loop_Name:
for my $i (1 .. 10) {
# ...
last Loop_Name; # Perl spells "break" as "last"
}

In both languages, if you omit the label on a break/exit/last statement
it applies to the innermost enclosing loop. Of course C would have to
do the same.

Off the top of my head, I can't think of a good simple syntax for loop
labels that's distinct from the syntax for goto labels, so perhaps a
"break name" construct could just refer to a goto label that's applied
to an iteration or switch statement. "break foo;" where "foo" is a
label that *doesn't* apply to an iteration or switch statement would be
a constraint violation.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: C23 (C2x) changes

<sigaf7$j1$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: C23 (C2x) changes
Date: Wed, 22 Sep 2021 23:24:32 +0100
Organization: A noiseless patient Spider
Lines: 62
Message-ID: <sigaf7$j1$1@dont-email.me>
References: <si99fr$ma4$1@dont-email.me> <sifsig$1ojn$1@gioia.aioe.org>
<sig3fm$91t$1@solani.org> <87mto4micx.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 22 Sep 2021 22:24:39 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="5587deda23d0b50a5b9d72dcb063de09";
logging-data="609"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+cDjMsbpUNTzwBtCz2cmM2Nm4e8lsEV/o="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:iyfCuuAIUyABqrJkpf1Z18pngEY=
In-Reply-To: <87mto4micx.fsf@nosuchdomain.example.com>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210922-8, 22/9/2021), Outbound message
 by: Bart - Wed, 22 Sep 2021 22:24 UTC

On 22/09/2021 22:05, Keith Thompson wrote:
> Philipp Klaus Krause <pkk@spth.de> writes:
>> Am 22.09.21 um 20:27 schrieb Guillaume:
>>
>>> - Tagged blocks/tagged loop constructs.
>>>
>>> […]
>>>
>>> That would be more elegant and easier to statically analyze than goto's.
>>
>> No. It would not be better than goto. Neither for users nor for static
>> analysis. AFAIK this has been proposed and rejected multiple times
>> before (e.g. N1989 at the London 2016 WG14 meeting).
>>
>> Regarding analysis (and likely also code readability), one important
>> parameter is the tree-width of the control-flow graph. For C this is
>> bounded by a constant plus the number of labels for goto used per
>> function. The situation is similar for many other languages. And at
>> least for tree-width, it has been proven that unlimited use of labeled
>> break / labeled continue, like Java has, would be just as bad as
>> unlimited use of goto.
>>
>> If you need to get out of an inner loop, just use goto. Avoiding goto by
>> introducing another variant of goto that just isn't called goto won't
>> make the standard better.
>
> The proposal in N1989
> http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1989.htm
> was to have "break 2;" break out of two enclosing loops. (The Bourne
> shell has this feature.) Personally, I dislike this. It's easy to
> forget to update the number when the code is rearranged, and it forces
> the programmer and reader to count nesting levels -- and counting, after
> all, is something that computers are really really good at.
>
> What I'd like to see is *named* loops, with "break" and "continue"
> optionally taking an argument that names the loop to be operated on.
> I've used other languages with this feature, and I've found it quite
> useful.

Named loops means having to invent names for things, which can be
annoying when the thing you're refering to is right there.

It makes it harder to copy and paste code within the same function,
since the loop names need to be revised. Unless you invent new scope
rules for those names so that they are local to that set of loops.

Also, if your intention is to break out of an entire set of nested
loops, you label the outer one, but then wrap it with an extra loop
level (or copy it into another loop), that 'outer' loop label may no
longer be the outermost.

I say, keep things simple. While I use numbered loops 1 (innermost) to N
(outermost), I also allow 0 to mean the outermost, so that most often
I'd write:

break # defaults to loop 1, innermost
break all # 'all' is a synonym for 0, so outermost

(Although my syntax uses 'exit' not break.)

Breaking out of any in-between loop is rare. For a start, you'd need 3
nested loop levels, itself uncommon.

Re: C23 (C2x) changes

<ef2dc441-6e2e-4f6b-b3a4-61e4a372fdeen@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:57d0:: with SMTP id w16mr2554597qta.96.1632361755419;
Wed, 22 Sep 2021 18:49:15 -0700 (PDT)
X-Received: by 2002:ac8:7003:: with SMTP id x3mr2587315qtm.284.1632361755197;
Wed, 22 Sep 2021 18:49:15 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Wed, 22 Sep 2021 18:49:14 -0700 (PDT)
In-Reply-To: <sigaf7$j1$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=189.6.249.78; posting-account=xFcAQAoAAAAoWlfpQ6Hz2n-MU9fthxbY
NNTP-Posting-Host: 189.6.249.78
References: <si99fr$ma4$1@dont-email.me> <sifsig$1ojn$1@gioia.aioe.org>
<sig3fm$91t$1@solani.org> <87mto4micx.fsf@nosuchdomain.example.com> <sigaf7$j1$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ef2dc441-6e2e-4f6b-b3a4-61e4a372fdeen@googlegroups.com>
Subject: Re: C23 (C2x) changes
From: thiago.a...@gmail.com (Thiago Adams)
Injection-Date: Thu, 23 Sep 2021 01:49:15 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 88
 by: Thiago Adams - Thu, 23 Sep 2021 01:49 UTC

On Wednesday, September 22, 2021 at 7:24:45 PM UTC-3, Bart wrote:
> On 22/09/2021 22:05, Keith Thompson wrote:
> > Philipp Klaus Krause <p...@spth.de> writes:
> >> Am 22.09.21 um 20:27 schrieb Guillaume:
> >>
> >>> - Tagged blocks/tagged loop constructs.
> >>>
> >>> […]
> >>>
> >>> That would be more elegant and easier to statically analyze than goto's.
> >>
> >> No. It would not be better than goto. Neither for users nor for static
> >> analysis. AFAIK this has been proposed and rejected multiple times
> >> before (e.g. N1989 at the London 2016 WG14 meeting).
> >>
> >> Regarding analysis (and likely also code readability), one important
> >> parameter is the tree-width of the control-flow graph. For C this is
> >> bounded by a constant plus the number of labels for goto used per
> >> function. The situation is similar for many other languages. And at
> >> least for tree-width, it has been proven that unlimited use of labeled
> >> break / labeled continue, like Java has, would be just as bad as
> >> unlimited use of goto.
> >>
> >> If you need to get out of an inner loop, just use goto. Avoiding goto by
> >> introducing another variant of goto that just isn't called goto won't
> >> make the standard better.
> >
> > The proposal in N1989
> > http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1989.htm
> > was to have "break 2;" break out of two enclosing loops. (The Bourne
> > shell has this feature.) Personally, I dislike this. It's easy to
> > forget to update the number when the code is rearranged, and it forces
> > the programmer and reader to count nesting levels -- and counting, after
> > all, is something that computers are really really good at.
> >
> > What I'd like to see is *named* loops, with "break" and "continue"
> > optionally taking an argument that names the loop to be operated on.
> > I've used other languages with this feature, and I've found it quite
> > useful.
> Named loops means having to invent names for things, which can be
> annoying when the thing you're refering to is right there.
>
> It makes it harder to copy and paste code within the same function,
> since the loop names need to be revised. Unless you invent new scope
> rules for those names so that they are local to that set of loops.
>
> Also, if your intention is to break out of an entire set of nested
> loops, you label the outer one, but then wrap it with an extra loop
> level (or copy it into another loop), that 'outer' loop label may no
> longer be the outermost.
>
> I say, keep things simple. While I use numbered loops 1 (innermost) to N
> (outermost), I also allow 0 to mean the outermost, so that most often
> I'd write:
>
> break # defaults to loop 1, innermost
> break all # 'all' is a synonym for 0, so outermost
>
> (Although my syntax uses 'exit' not break.)
>
> Breaking out of any in-between loop is rare. For a start, you'd need 3
> nested loop levels, itself uncommon.

If you have a label it is as bad as goto.

We need more kinds of structured jumps.
I have suggested try throw catch (because I didn't find better name)
that are basically a local jump to catch - doesn't matter if you are inside
loops or not.

Traditional loop operators are so old and all the languages
have the same, so it's hard to get used to new jump names.

Re: C23 (C2x) changes

<siib3l$1i8b$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!Smk/rEQ09ac3o4C3SZ0ZJg.user.46.165.242.75.POSTED!not-for-mail
From: mess...@bottle.org (Guillaume)
Newsgroups: comp.lang.c
Subject: Re: C23 (C2x) changes
Date: Thu, 23 Sep 2021 18:47:45 +0200
Organization: Aioe.org NNTP Server
Message-ID: <siib3l$1i8b$1@gioia.aioe.org>
References: <si99fr$ma4$1@dont-email.me> <sifsig$1ojn$1@gioia.aioe.org>
<sig3fm$91t$1@solani.org> <87mto4micx.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="51467"; posting-host="Smk/rEQ09ac3o4C3SZ0ZJg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Content-Language: fr
X-Notice: Filtered by postfilter v. 0.9.2
 by: Guillaume - Thu, 23 Sep 2021 16:47 UTC

Le 22/09/2021 à 23:05, Keith Thompson a écrit :
> Philipp Klaus Krause <pkk@spth.de> writes:
>> Am 22.09.21 um 20:27 schrieb Guillaume:
>>
>>> - Tagged blocks/tagged loop constructs.
>>>
>>> […]
>>>
>>> That would be more elegant and easier to statically analyze than goto's.
>>
>> No. It would not be better than goto. Neither for users nor for static
>> analysis. AFAIK this has been proposed and rejected multiple times
>> before (e.g. N1989 at the London 2016 WG14 meeting).
>>
>> Regarding analysis (and likely also code readability), one important
>> parameter is the tree-width of the control-flow graph. For C this is
>> bounded by a constant plus the number of labels for goto used per
>> function. The situation is similar for many other languages. And at
>> least for tree-width, it has been proven that unlimited use of labeled
>> break / labeled continue, like Java has, would be just as bad as
>> unlimited use of goto.
>>
>> If you need to get out of an inner loop, just use goto. Avoiding goto by
>> introducing another variant of goto that just isn't called goto won't
>> make the standard better.
>
> The proposal in N1989
> http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1989.htm
> was to have "break 2;" break out of two enclosing loops. (The Bourne
> shell has this feature.) Personally, I dislike this. It's easy to
> forget to update the number when the code is rearranged, and it forces
> the programmer and reader to count nesting levels -- and counting, after
> all, is something that computers are really really good at.

It is indeed atrocious. And nothing like what I suggested.

>
> What I'd like to see is *named* loops, with "break" and "continue"
> optionally taking an argument that names the loop to be operated on.
> I've used other languages with this feature, and I've found it quite
> useful.

Yes, this is exactly what I suggested.
And yes, this is useful, clear to read, and much better than goto's that
are not attached to any structure.

Static bounds checking (was Re: C23 (C2x) changes)

<sovv1i-kui1.ln1@wilbur.25thandClement.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!buffer2.nntp.dca1.giganews.com!buffer1.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Thu, 23 Sep 2021 23:15:02 -0500
Message-ID: <sovv1i-kui1.ln1@wilbur.25thandClement.com>
From: will...@25thandClement.com (William Ahern)
Subject: Static bounds checking (was Re: C23 (C2x) changes)
Newsgroups: comp.lang.c
References: <si99fr$ma4$1@dont-email.me>
User-Agent: tin/2.4.4-20191224 ("Millburn") (OpenBSD/6.9 (amd64))
Date: Thu, 23 Sep 2021 21:11:40 -0700
Lines: 15
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-88fTcF+UD9hRGF14Lxlltm0dkOKodIQKAT9HHmyWm/bKO06Ztyasnn4BcHKqxahzaDYkSGMCkcKEBwo!4AYBfzUy3mvVIYDu4BS8p+leQh83qeJqJ0skwqnju8NsRNjL/VXSzpUsxtSoqaCDWJQ=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 1550
 by: William Ahern - Fri, 24 Sep 2021 04:11 UTC

Mehdi Amini <atorrses@gmail.com> wrote:
> Hi,
>
> It seems these are some of changes for C23(C2x) standard taken from
> draft documents:
>
> https://en.cppreference.com/w/c/23
> https://thephd.dev/c-the-improvements-june-september-virtual-c-meeting

Does anybody know how well received have been the various proposals for
improving static bounds checking? Most proposals build on function
declarator VLA syntax. That seems like the path of least resistance. Though,
perhaps the backwards compatibility headaches silently make it the path of
*most* resistance...?

Re: Static bounds checking (was Re: C23 (C2x) changes)

<sijsif$k9m$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Static bounds checking (was Re: C23 (C2x) changes)
Date: Fri, 24 Sep 2021 08:51:59 +0200
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <sijsif$k9m$1@dont-email.me>
References: <si99fr$ma4$1@dont-email.me>
<sovv1i-kui1.ln1@wilbur.25thandClement.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 24 Sep 2021 06:52:00 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="401401d4f7b95a605dbc1df9c71000de";
logging-data="20790"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18qupLqMzKEy1JK5LH3ckRNbRZXqqFw9Bg="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:6bIfNmACN4u+sfDl0qHVYifu6HA=
In-Reply-To: <sovv1i-kui1.ln1@wilbur.25thandClement.com>
Content-Language: en-GB
 by: David Brown - Fri, 24 Sep 2021 06:51 UTC

On 24/09/2021 06:11, William Ahern wrote:
> Mehdi Amini <atorrses@gmail.com> wrote:
>> Hi,
>>
>> It seems these are some of changes for C23(C2x) standard taken from
>> draft documents:
>>
>> https://en.cppreference.com/w/c/23
>> https://thephd.dev/c-the-improvements-june-september-virtual-c-meeting
>
> Does anybody know how well received have been the various proposals for
> improving static bounds checking? Most proposals build on function
> declarator VLA syntax. That seems like the path of least resistance. Though,
> perhaps the backwards compatibility headaches silently make it the path of
> *most* resistance...?
>

Have you examples of what you mean here? I don't understand what you
are talking about - perhaps because I am unfamiliar with the relevant
proposals.

If you are thinking of the "Annex K Bounds-checking interface"
functions, that was, AFAIK, a total flop. It is overly complex,
inconvenient, doesn't do what people want, and is unlikely to make
anything safer or more reliable in any way - /if/ any toolchain and
library bothered to implement it. (If anyone has contradictory
arguments, I'd love to hear them.)

Re: Static bounds checking (was Re: C23 (C2x) changes)

<sijuqt$s3f$1@solani.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From: pkk...@spth.de (Philipp Klaus Krause)
Newsgroups: comp.lang.c
Subject: Re: Static bounds checking (was Re: C23 (C2x) changes)
Date: Fri, 24 Sep 2021 09:30:36 +0200
Message-ID: <sijuqt$s3f$1@solani.org>
References: <si99fr$ma4$1@dont-email.me>
<sovv1i-kui1.ln1@wilbur.25thandClement.com> <sijsif$k9m$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 24 Sep 2021 07:30:37 -0000 (UTC)
Injection-Info: solani.org;
logging-data="28783"; mail-complaints-to="abuse@news.solani.org"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Cancel-Lock: sha1:2d0fk+jJIsKMFfeydatZgNZFyXA=
In-Reply-To: <sijsif$k9m$1@dont-email.me>
X-User-ID: eJwFwYEBwCAIA7CXZKMtnCOu/n/CErwMHiXBxMXt1c5ytD82BTm1oTpniPAye02pntCWJ34OfxCX
Content-Language: en-US
 by: Philipp Klaus Krause - Fri, 24 Sep 2021 07:30 UTC

Am 24.09.21 um 08:51 schrieb David Brown:
> On 24/09/2021 06:11, William Ahern wrote:
>> Mehdi Amini <atorrses@gmail.com> wrote:
>>> Hi,
>>>
>>> It seems these are some of changes for C23(C2x) standard taken from
>>> draft documents:
>>>
>>> https://en.cppreference.com/w/c/23
>>> https://thephd.dev/c-the-improvements-june-september-virtual-c-meeting
>>
>> Does anybody know how well received have been the various proposals for
>> improving static bounds checking? Most proposals build on function
>> declarator VLA syntax. That seems like the path of least resistance. Though,
>> perhaps the backwards compatibility headaches silently make it the path of
>> *most* resistance...?
>>
>
> Have you examples of what you mean here? I don't understand what you
> are talking about - perhaps because I am unfamiliar with the relevant
> proposals.
>

N2660, N2779.

AFAIR due to lack of time it wasn't discusses at this meeting. At the
previous one, there was discussion, but no vote (see the minutes N2802).

Re: Static bounds checking (was Re: C23 (C2x) changes)

<ptf3J.44292$ol1.39305@fx42.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx42.iad.POSTED!not-for-mail
Newsgroups: comp.lang.c
From: branimir...@gmail.com (Branimir Maksimovic)
Subject: Re: Static bounds checking (was Re: C23 (C2x) changes)
References: <si99fr$ma4$1@dont-email.me>
<sovv1i-kui1.ln1@wilbur.25thandClement.com>
User-Agent: slrn/1.0.3 (Darwin)
Lines: 27
Message-ID: <ptf3J.44292$ol1.39305@fx42.iad>
X-Complaints-To: abuse@usenet-news.net
NNTP-Posting-Date: Fri, 24 Sep 2021 07:52:53 UTC
Organization: usenet-news.net
Date: Fri, 24 Sep 2021 07:52:53 GMT
X-Received-Bytes: 1404
 by: Branimir Maksimovic - Fri, 24 Sep 2021 07:52 UTC

Such things should be *optional*, we are not *kids*.

--
7-77-777
\|/
---
/|\
On 2021-09-24, William Ahern <william@25thandClement.com> wrote:
> Mehdi Amini <atorrses@gmail.com> wrote:
>> Hi,
>>
>> It seems these are some of changes for C23(C2x) standard taken from
>> draft documents:
>>
>> https://en.cppreference.com/w/c/23
>> https://thephd.dev/c-the-improvements-june-september-virtual-c-meeting
>
> Does anybody know how well received have been the various proposals for
> improving static bounds checking? Most proposals build on function
> declarator VLA syntax. That seems like the path of least resistance. Though,
> perhaps the backwards compatibility headaches silently make it the path of
> *most* resistance...?
>

--
Evil Sinner!

Re: Static bounds checking (was Re: C23 (C2x) changes)

<sik9gb$116$1@solani.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From: pkk...@spth.de (Philipp Klaus Krause)
Newsgroups: comp.lang.c
Subject: Re: Static bounds checking (was Re: C23 (C2x) changes)
Date: Fri, 24 Sep 2021 12:32:43 +0200
Message-ID: <sik9gb$116$1@solani.org>
References: <si99fr$ma4$1@dont-email.me>
<sovv1i-kui1.ln1@wilbur.25thandClement.com> <ptf3J.44292$ol1.39305@fx42.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 24 Sep 2021 10:32:43 -0000 (UTC)
Injection-Info: solani.org;
logging-data="1062"; mail-complaints-to="abuse@news.solani.org"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Cancel-Lock: sha1:BFtMemILQZ7WyA6VviBl47eS/II=
In-Reply-To: <ptf3J.44292$ol1.39305@fx42.iad>
Content-Language: en-US
X-User-ID: eJwFwYEBwDAEBMCViPdhHCX2H6F3blT2BZ3w9eXNOPbiaA06k9PzslxWT3ysmTCJgakA0vYDFPcQpA==
 by: Philipp Klaus Krause - Fri, 24 Sep 2021 10:32 UTC

Am 24.09.21 um 09:52 schrieb Branimir Maksimovic:
> Such things should be *optional*, we are not *kids*.
>

It is optional: You can always use pointer parameters to pass your
arrays to your functions instead of VLA parameters.

Philipp

Re: Static bounds checking (was Re: C23 (C2x) changes)

<q3i3J.84531$g81.37380@fx33.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx33.iad.POSTED!not-for-mail
Newsgroups: comp.lang.c
From: branimir...@gmail.com (Branimir Maksimovic)
Subject: Re: Static bounds checking (was Re: C23 (C2x) changes)
References: <si99fr$ma4$1@dont-email.me>
<sovv1i-kui1.ln1@wilbur.25thandClement.com>
<ptf3J.44292$ol1.39305@fx42.iad> <sik9gb$116$1@solani.org>
User-Agent: slrn/1.0.3 (Darwin)
Lines: 19
Message-ID: <q3i3J.84531$g81.37380@fx33.iad>
X-Complaints-To: abuse@usenet-news.net
NNTP-Posting-Date: Fri, 24 Sep 2021 10:49:58 UTC
Organization: usenet-news.net
Date: Fri, 24 Sep 2021 10:49:58 GMT
X-Received-Bytes: 1111
 by: Branimir Maksimovic - Fri, 24 Sep 2021 10:49 UTC

What's purpose of VLA then? I always used alloca for that?

--
7-77-777
\|/
/|\
On 2021-09-24, Philipp Klaus Krause <pkk@spth.de> wrote:
> Am 24.09.21 um 09:52 schrieb Branimir Maksimovic:
>> Such things should be *optional*, we are not *kids*.
>>
>
> It is optional: You can always use pointer parameters to pass your
> arrays to your functions instead of VLA parameters.
>
> Philipp

--
Evil Sinner!

Re: Static bounds checking (was Re: C23 (C2x) changes)

<sikhbe$5gk$1@solani.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From: pkk...@spth.de (Philipp Klaus Krause)
Newsgroups: comp.lang.c
Subject: Re: Static bounds checking (was Re: C23 (C2x) changes)
Date: Fri, 24 Sep 2021 14:46:38 +0200
Message-ID: <sikhbe$5gk$1@solani.org>
References: <si99fr$ma4$1@dont-email.me>
<sovv1i-kui1.ln1@wilbur.25thandClement.com> <ptf3J.44292$ol1.39305@fx42.iad>
<sik9gb$116$1@solani.org> <q3i3J.84531$g81.37380@fx33.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 24 Sep 2021 12:46:38 -0000 (UTC)
Injection-Info: solani.org;
logging-data="5652"; mail-complaints-to="abuse@news.solani.org"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Cancel-Lock: sha1:WBxvpMCE9EZ2AFnIwdYca8JW460=
In-Reply-To: <q3i3J.84531$g81.37380@fx33.iad>
X-User-ID: eJwFwQEBwCAMAzBLZ6MdkwOF+pfwBMlB1SQ4YdgX2Ymg4qq1KjYI6wyiX6vWap35yd603g8c0hGy
Content-Language: en-US
 by: Philipp Klaus Krause - Fri, 24 Sep 2021 12:46 UTC

Am 24.09.21 um 12:49 schrieb Branimir Maksimovic:
> What's purpose of VLA then? I always used alloca for that?
>

Both VLAs and alloca can be used to allocate memory (though alloca is
non-standard, and VLAs are optional since C11).
But VLA types can also be used for other purposes, in particular as the
type of a function parameter, which is the use relevant to this discussion.

Re: Static bounds checking (was Re: C23 (C2x) changes)

<sikth7$vpc$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: Static bounds checking (was Re: C23 (C2x) changes)
Date: Fri, 24 Sep 2021 18:14:31 +0200
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <sikth7$vpc$1@dont-email.me>
References: <si99fr$ma4$1@dont-email.me>
<sovv1i-kui1.ln1@wilbur.25thandClement.com> <ptf3J.44292$ol1.39305@fx42.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 24 Sep 2021 16:14:31 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="a71256d5c34b43cdc822e707f5389beb";
logging-data="32556"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+fLfdz5EITx672CTaDGIYgO4zcgk26gKk="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Cancel-Lock: sha1:a5e4CQzCSpsrKuV49AMlaZXFyok=
In-Reply-To: <ptf3J.44292$ol1.39305@fx42.iad>
Content-Language: de-DE
 by: Bonita Montero - Fri, 24 Sep 2021 16:14 UTC

Am 24.09.2021 um 09:52 schrieb Branimir Maksimovic:
> Such things should be *optional*, we are not *kids*.

There seem to be a lot of kids since buffer-overflow-errors are very
common in C. C++ in contrast provides []-operator and iterators which
have very convenient debug-boundschecking.

>
> --
> 7-77-777
> \|/
> ---
> /|\
> On 2021-09-24, William Ahern <william@25thandClement.com> wrote:
>> Mehdi Amini <atorrses@gmail.com> wrote:
>>> Hi,
>>>
>>> It seems these are some of changes for C23(C2x) standard taken from
>>> draft documents:
>>>
>>> https://en.cppreference.com/w/c/23
>>> https://thephd.dev/c-the-improvements-june-september-virtual-c-meeting
>>
>> Does anybody know how well received have been the various proposals for
>> improving static bounds checking? Most proposals build on function
>> declarator VLA syntax. That seems like the path of least resistance. Though,
>> perhaps the backwards compatibility headaches silently make it the path of
>> *most* resistance...?
>>
>
>

Re: Static bounds checking (was Re: C23 (C2x) changes)

<8xu3J.74157$QzOf.42137@fx17.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx17.iad.POSTED!not-for-mail
Newsgroups: comp.lang.c
From: branimir...@gmail.com (Branimir Maksimovic)
Subject: Re: Static bounds checking (was Re: C23 (C2x) changes)
References: <si99fr$ma4$1@dont-email.me>
<sovv1i-kui1.ln1@wilbur.25thandClement.com>
<ptf3J.44292$ol1.39305@fx42.iad> <sikth7$vpc$1@dont-email.me>
User-Agent: slrn/1.0.3 (Darwin)
Lines: 45
Message-ID: <8xu3J.74157$QzOf.42137@fx17.iad>
X-Complaints-To: abuse@usenet-news.net
NNTP-Posting-Date: Sat, 25 Sep 2021 01:00:52 UTC
Organization: usenet-news.net
Date: Sat, 25 Sep 2021 01:00:52 GMT
X-Received-Bytes: 1996
 by: Branimir Maksimovic - Sat, 25 Sep 2021 01:00 UTC

Look, bounds checking is costly, if done in run time, and people think that
using to_string is not efficient :P

--
7-77-777
\|/
---
/|\
On 2021-09-24, Bonita Montero <Bonita.Montero@gmail.com> wrote:
> Am 24.09.2021 um 09:52 schrieb Branimir Maksimovic:
>> Such things should be *optional*, we are not *kids*.
>
> There seem to be a lot of kids since buffer-overflow-errors are very
> common in C. C++ in contrast provides []-operator and iterators which
> have very convenient debug-boundschecking.
>
>>
>> --
>> 7-77-777
>> \|/
>> ---
>> /|\
>> On 2021-09-24, William Ahern <william@25thandClement.com> wrote:
>>> Mehdi Amini <atorrses@gmail.com> wrote:
>>>> Hi,
>>>>
>>>> It seems these are some of changes for C23(C2x) standard taken from
>>>> draft documents:
>>>>
>>>> https://en.cppreference.com/w/c/23
>>>> https://thephd.dev/c-the-improvements-june-september-virtual-c-meeting
>>>
>>> Does anybody know how well received have been the various proposals for
>>> improving static bounds checking? Most proposals build on function
>>> declarator VLA syntax. That seems like the path of least resistance. Though,
>>> perhaps the backwards compatibility headaches silently make it the path of
>>> *most* resistance...?
>>>
>>
>>
>

--
Evil Sinner!

Re: Static bounds checking (was Re: C23 (C2x) changes)

<simcvk$r2n$1@solani.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From: pkk...@spth.de (Philipp Klaus Krause)
Newsgroups: comp.lang.c
Subject: Re: Static bounds checking (was Re: C23 (C2x) changes)
Date: Sat, 25 Sep 2021 07:44:20 +0200
Message-ID: <simcvk$r2n$1@solani.org>
References: <si99fr$ma4$1@dont-email.me>
<sovv1i-kui1.ln1@wilbur.25thandClement.com> <ptf3J.44292$ol1.39305@fx42.iad>
<sikth7$vpc$1@dont-email.me> <8xu3J.74157$QzOf.42137@fx17.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 25 Sep 2021 05:44:20 -0000 (UTC)
Injection-Info: solani.org;
logging-data="27735"; mail-complaints-to="abuse@news.solani.org"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Cancel-Lock: sha1:w0/jr7TFItPh9ug+XxtBLzGsr2s=
X-User-ID: eJwNxsEBgEAIA7CVTmkLjCMI+4+geYWmS+0QBS731FQ8zfxrYycLsy8CYUmA2LuOvEnOUv4BHjIQtg==
In-Reply-To: <8xu3J.74157$QzOf.42137@fx17.iad>
Content-Language: en-US
 by: Philipp Klaus Krause - Sat, 25 Sep 2021 05:44 UTC

Am 25.09.21 um 03:00 schrieb Branimir Maksimovic:
> Look, bounds checking is costly, if done in run time, […]

Yes. But unlike Annex K, which is about runtime bounds checking, the
features now discussed for C23 are about improving static bounds
checking, i.e. compile-time bounds checking. Via array types, including
VLA types, as function parameters. This could allow both improved
diagnostics and optimization in the callee.

AFAIR the main problem is that the syntax already has a meaning (an
array currently just decays to a pointer). But maybe actual use is
uncommen enough that it can still be changed.

Re: Static bounds checking (was Re: C23 (C2x) changes)

<simk7g$afa$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: Static bounds checking (was Re: C23 (C2x) changes)
Date: Sat, 25 Sep 2021 09:48:01 +0200
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <simk7g$afa$1@dont-email.me>
References: <si99fr$ma4$1@dont-email.me>
<sovv1i-kui1.ln1@wilbur.25thandClement.com> <ptf3J.44292$ol1.39305@fx42.iad>
<sikth7$vpc$1@dont-email.me> <8xu3J.74157$QzOf.42137@fx17.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 25 Sep 2021 07:48:00 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f61e0663b04488e36f72c12ad3990597";
logging-data="10730"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+elu8XHaPjElSaIpd1avMlKyfKszuUZV8="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Cancel-Lock: sha1:zQB1xjiv6dlgqVL/Of7ExhAWcJM=
In-Reply-To: <8xu3J.74157$QzOf.42137@fx17.iad>
Content-Language: de-DE
 by: Bonita Montero - Sat, 25 Sep 2021 07:48 UTC

> Look, bounds checking is costly, if done in run time, and people think that
> using to_string is not efficient :P

Bounds-checking is only costly when you have random-access array access.
If you iterate linearely the loop will be split in three passes by the
optimizer: the part before the begin of the array, the part within the
array and the part afterwards; that's how Java and Rust do it. And Rust
isn't significantly slower than C or c++.

Re: Static bounds checking (was Re: C23 (C2x) changes)

<XJD3J.125617$F26.95788@fx44.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!news.uzoreto.com!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx44.iad.POSTED!not-for-mail
Newsgroups: comp.lang.c
From: branimir...@gmail.com (Branimir Maksimovic)
Subject: Re: Static bounds checking (was Re: C23 (C2x) changes)
References: <si99fr$ma4$1@dont-email.me>
<sovv1i-kui1.ln1@wilbur.25thandClement.com>
<ptf3J.44292$ol1.39305@fx42.iad> <sikth7$vpc$1@dont-email.me>
<8xu3J.74157$QzOf.42137@fx17.iad> <simcvk$r2n$1@solani.org>
User-Agent: slrn/1.0.3 (Darwin)
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Lines: 20
Message-ID: <XJD3J.125617$F26.95788@fx44.iad>
X-Complaints-To: abuse@usenet-news.net
NNTP-Posting-Date: Sat, 25 Sep 2021 11:28:55 UTC
Organization: usenet-news.net
Date: Sat, 25 Sep 2021 11:28:55 GMT
X-Received-Bytes: 1699
 by: Branimir Maksimovic - Sat, 25 Sep 2021 11:28 UTC

On 2021-09-25, Philipp Klaus Krause <pkk@spth.de> wrote:
> Am 25.09.21 um 03:00 schrieb Branimir Maksimovic:
>> Look, bounds checking is costly, if done in run time, […]
>
> Yes. But unlike Annex K, which is about runtime bounds checking, the
> features now discussed for C23 are about improving static bounds
> checking, i.e. compile-time bounds checking. Via array types, including
> VLA types, as function parameters. This could allow both improved
> diagnostics and optimization in the callee.
>
> AFAIR the main problem is that the syntax already has a meaning (an
> array currently just decays to a pointer). But maybe actual use is
> uncommen enough that it can still be changed.

Problem is that, in order that to work, how you can check, when using
malloc or passing array to library function?

--
7-77-777
Evil Sinner!

Re: Static bounds checking (was Re: C23 (C2x) changes)

<LLD3J.125618$F26.58164@fx44.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx44.iad.POSTED!not-for-mail
Newsgroups: comp.lang.c
From: branimir...@gmail.com (Branimir Maksimovic)
Subject: Re: Static bounds checking (was Re: C23 (C2x) changes)
References: <si99fr$ma4$1@dont-email.me>
<sovv1i-kui1.ln1@wilbur.25thandClement.com>
<ptf3J.44292$ol1.39305@fx42.iad> <sikth7$vpc$1@dont-email.me>
<8xu3J.74157$QzOf.42137@fx17.iad> <simk7g$afa$1@dont-email.me>
User-Agent: slrn/1.0.3 (Darwin)
Lines: 18
Message-ID: <LLD3J.125618$F26.58164@fx44.iad>
X-Complaints-To: abuse@usenet-news.net
NNTP-Posting-Date: Sat, 25 Sep 2021 11:30:51 UTC
Organization: usenet-news.net
Date: Sat, 25 Sep 2021 11:30:51 GMT
X-Received-Bytes: 1440
 by: Branimir Maksimovic - Sat, 25 Sep 2021 11:30 UTC

On 2021-09-25, Bonita Montero <Bonita.Montero@gmail.com> wrote:
>> Look, bounds checking is costly, if done in run time, and people think that
>> using to_string is not efficient :P
>
> Bounds-checking is only costly when you have random-access array access.
> If you iterate linearely the loop will be split in three passes by the
> optimizer: the part before the begin of the array, the part within the
> array and the part afterwards; that's how Java and Rust do it. And Rust
> isn't significantly slower than C or c++.
>

That's costly.
Fact when iterating over array hides it (because of cache), but not all accesses
are sequential.

--
7-77-777
Evil Sinner!

Re: Static bounds checking (was Re: C23 (C2x) changes)

<20210925134720.515@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 480-992-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Static bounds checking (was Re: C23 (C2x) changes)
Date: Sat, 25 Sep 2021 20:49:21 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <20210925134720.515@kylheku.com>
References: <si99fr$ma4$1@dont-email.me>
<sovv1i-kui1.ln1@wilbur.25thandClement.com>
<ptf3J.44292$ol1.39305@fx42.iad> <sikth7$vpc$1@dont-email.me>
<8xu3J.74157$QzOf.42137@fx17.iad> <simk7g$afa$1@dont-email.me>
<LLD3J.125618$F26.58164@fx44.iad>
Injection-Date: Sat, 25 Sep 2021 20:49:21 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="60ab0db9402d19c44102d477a87b5b37";
logging-data="12136"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Fza/BL+Pjq+/bIpu8eHj6GnJ0WnyXCWg="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:A5peyprdvdetYaIOXUnWfw347xY=
 by: Kaz Kylheku - Sat, 25 Sep 2021 20:49 UTC

On 2021-09-25, Branimir Maksimovic <branimir.maksimovic@gmail.com> wrote:
> On 2021-09-25, Bonita Montero <Bonita.Montero@gmail.com> wrote:
>>> Look, bounds checking is costly, if done in run time, and people think that
>>> using to_string is not efficient :P
>>
>> Bounds-checking is only costly when you have random-access array access.
>> If you iterate linearely the loop will be split in three passes by the
>> optimizer: the part before the begin of the array, the part within the
>> array and the part afterwards; that's how Java and Rust do it. And Rust
>> isn't significantly slower than C or c++.
>>
>
> That's costly.
> Fact when iterating over array hides it (because of cache), but not all accesses
> are sequential.

Never mind caching; when you're iterating over an array, you can hoist
the bounds check out of the loop (if you know that the loop has no
termination condition other than the array bounds).

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Re: Static bounds checking (was Re: C23 (C2x) changes)

<AOO3J.85367$z%4.84981@fx37.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!newsfeed.xs4all.nl!newsfeed9.news.xs4all.nl!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx37.iad.POSTED!not-for-mail
Newsgroups: comp.lang.c
From: branimir...@gmail.com (Branimir Maksimovic)
Subject: Re: Static bounds checking (was Re: C23 (C2x) changes)
References: <si99fr$ma4$1@dont-email.me>
<sovv1i-kui1.ln1@wilbur.25thandClement.com>
<ptf3J.44292$ol1.39305@fx42.iad> <sikth7$vpc$1@dont-email.me>
<8xu3J.74157$QzOf.42137@fx17.iad> <simk7g$afa$1@dont-email.me>
<LLD3J.125618$F26.58164@fx44.iad> <20210925134720.515@kylheku.com>
User-Agent: slrn/1.0.3 (Darwin)
Lines: 20
Message-ID: <AOO3J.85367$z%4.84981@fx37.iad>
X-Complaints-To: abuse@usenet-news.net
NNTP-Posting-Date: Sun, 26 Sep 2021 00:04:48 UTC
Organization: usenet-news.net
Date: Sun, 26 Sep 2021 00:04:48 GMT
X-Received-Bytes: 1487
 by: Branimir Maksimovic - Sun, 26 Sep 2021 00:04 UTC

On 2021-09-25, Kaz Kylheku <480-992-1380@kylheku.com> wrote:
>>> optimizer: the part before the begin of the array, the part within the
>>> array and the part afterwards; that's how Java and Rust do it. And Rust
>>> isn't significantly slower than C or c++.
>>>
>>
>> That's costly.
>> Fact when iterating over array hides it (because of cache), but not all accesses
>> are sequential.
>
> Never mind caching; when you're iterating over an array, you can hoist
> the bounds check out of the loop (if you know that the loop has no
> termination condition other than the array bounds).
>
Thanks, I'll remember that.

--

7-77-777
Evil Sinner!

Re: Static bounds checking (was Re: C23 (C2x) changes)

<siouh4$88f$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: Static bounds checking (was Re: C23 (C2x) changes)
Date: Sun, 26 Sep 2021 06:56:05 +0200
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <siouh4$88f$1@dont-email.me>
References: <si99fr$ma4$1@dont-email.me>
<sovv1i-kui1.ln1@wilbur.25thandClement.com> <ptf3J.44292$ol1.39305@fx42.iad>
<sikth7$vpc$1@dont-email.me> <8xu3J.74157$QzOf.42137@fx17.iad>
<simk7g$afa$1@dont-email.me> <LLD3J.125618$F26.58164@fx44.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 26 Sep 2021 04:56:04 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="515ea02aabc440b8e31b406b1491c1f0";
logging-data="8463"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX189BLfSiJRMHafq5O40ee1nEsLBetR7VvI="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Cancel-Lock: sha1:qYkb37KBRmRfh1rhG2kmHz4YbMU=
In-Reply-To: <LLD3J.125618$F26.58164@fx44.iad>
Content-Language: de-DE
 by: Bonita Montero - Sun, 26 Sep 2021 04:56 UTC

Am 25.09.2021 um 13:30 schrieb Branimir Maksimovic:
> On 2021-09-25, Bonita Montero <Bonita.Montero@gmail.com> wrote:
>>> Look, bounds checking is costly, if done in run time, and people think that
>>> using to_string is not efficient :P
>>
>> Bounds-checking is only costly when you have random-access array access.
>> If you iterate linearely the loop will be split in three passes by the
>> optimizer: the part before the begin of the array, the part within the
>> array and the part afterwards; that's how Java and Rust do it. And Rust
>> isn't significantly slower than C or c++.
>>
>
> That's costly.

No, this linear optimization almost costs nothing. The loops before
and afterwards are only there to throw out of bounds exceptions if
array-elements are actually touched.

Re: C23 (C2x) changes

<sisn5m$ni6$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!Puiiztk9lHEEQC0y3uUjRA.user.46.165.242.75.POSTED!not-for-mail
From: non...@add.invalid (Manfred)
Newsgroups: comp.lang.c
Subject: Re: C23 (C2x) changes
Date: Mon, 27 Sep 2021 17:15:01 +0200
Organization: Aioe.org NNTP Server
Message-ID: <sisn5m$ni6$1@gioia.aioe.org>
References: <si99fr$ma4$1@dont-email.me> <siaa3b$t76$1@dont-email.me>
<siac7m$8r0$1@dont-email.me> <siahul$tb8$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="24134"; posting-host="Puiiztk9lHEEQC0y3uUjRA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Manfred - Mon, 27 Sep 2021 15:15 UTC

On 9/20/2021 7:55 PM, Bart wrote:
> On 20/09/2021 17:17, David Brown wrote:
>> On 20/09/2021 17:41, John Bode wrote:
>
>>> If signed integer representations other than two's complement will
>>> no longer be supported, does this mean signed integer overflow can
>>> have a well-defined behavior?  Or will it still be left undefined
>>> to allow for optimizations?  Or could that be controlled with one
>>> of these newfangled attribute thingies?
>>
>>
>> No, signed integer overflow is still undefined behaviour - for which I
>> am very glad.  Defining it is terrible, IMHO, since any definition you
>> give will be the wrong answer.  Some would want it defined as wrapping
>> ($DEITY knows why, since it is the silliest of all definitions despite
>> being fairly efficient to implement), some would want it as an error or
>> a trap, some would want saturation, some would want a NaN, some would
>> want errno to be set.
>>
>> For those that think it makes sense to have a pile of 2147483647 apples,
>> add another apple to the pile, and end up with -2147483648 apples, gcc
>> still has the "-fwrapv" option.
>
> Of course it makes perfect sense to have a pile of 4294967295 apples,
> add another apple to the pile, and suddenly end up with 0 apples!
>
> Meanwhile, someone could remove that extra apple from the pile of
> -2147483648, to restore the original 2147483647, however that's too
> late: the overflow police have already been, and will do so again even
> when it becomes legal.
>

It's all about modeling a problem domain.
In mathematics, /integer/ arithmetic (the one you use a.o. to add and
subtract things) is /signed/ (for any serious work, at least).
The tool that C offers to model this domain is signed integers - with
the unavoidable limitations of limited size.

Unsigned integers are the tool that C offers for /binary/ arithmetic. In
this context wrapping is one of the features that makes them useful.

Re: C23 (C2x) changes

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

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: C23 (C2x) changes
Date: Mon, 27 Sep 2021 17:38:23 +0100
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <87y27it1mo.fsf@bsb.me.uk>
References: <si99fr$ma4$1@dont-email.me> <siaa3b$t76$1@dont-email.me>
<siac7m$8r0$1@dont-email.me> <siahul$tb8$1@dont-email.me>
<sisn5m$ni6$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="ce3555c1b77951a5ab0444e85ab5bb1e";
logging-data="27649"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19LU66xY/xET+fJgisdZbtk+cZ6FCcORD0="
Cancel-Lock: sha1:y2hTNR0Ln+M3FeFnJaWPg8efKcM=
sha1:EkymZi4IBeQLA6bD/F6Ux2OgzBg=
X-BSB-Auth: 1.3c9dadb0610856a27596.20210927173823BST.87y27it1mo.fsf@bsb.me.uk
 by: Ben Bacarisse - Mon, 27 Sep 2021 16:38 UTC

Manfred <noname@add.invalid> writes:

> On 9/20/2021 7:55 PM, Bart wrote:

>> Of course it makes perfect sense to have a pile of 4294967295 apples,
>> add another apple to the pile, and suddenly end up with 0 apples!
>> Meanwhile, someone could remove that extra apple from the pile of
>> -2147483648, to restore the original 2147483647, however that's too
>> late: the overflow police have already been, and will do so again
>> even when it becomes legal.
>>
>
> It's all about modeling a problem domain.
> In mathematics, /integer/ arithmetic (the one you use a.o. to add and
> subtract things) is /signed/ (for any serious work, at least). The
> tool that C offers to model this domain is signed integers - with the
> unavoidable limitations of limited size.
>
> Unsigned integers are the tool that C offers for /binary/
> arithmetic. In this context wrapping is one of the features that makes
> them useful.

Some mathematics concerns the natural numbers. Unsigned integer types
would be an entirely natural (no pun intended) choice for these cases.

--
Ben.

Pages:12345
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor