Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

All constants are variables.


computers / comp.os.vms / Re: VMS Cobol - GnuCOBOL

SubjectAuthor
* VMS Cobol - GnuCOBOLArne Vajhøj
+- Re: VMS Cobol - GnuCOBOLNeil Rieck
+* Re: VMS Cobol - GnuCOBOLultr...@gmail.com
|+* Re: VMS Cobol - GnuCOBOLbill
||`* Re: VMS Cobol - GnuCOBOLArne Vajhøj
|| `* Re: VMS Cobol - GnuCOBOLSimon Clubley
||  +* Re: VMS Cobol - GnuCOBOLDave Froble
||  |`* Re: VMS Cobol - GnuCOBOLSimon Clubley
||  | `* Re: VMS Cobol - GnuCOBOLArne Vajhøj
||  |  `* Re: VMS Cobol - GnuCOBOLDenys Beauchemin
||  |   +* Re: VMS Cobol - GnuCOBOLSingle Stage to Orbit
||  |   |+* Re: VMS Cobol - GnuCOBOLPaul Gavin
||  |   ||+- Re: VMS Cobol - GnuCOBOLDenys Beauchemin
||  |   ||`* Re: VMS Cobol - GnuCOBOLScott Dorsey
||  |   || `* Re: VMS Cobol - GnuCOBOLbill
||  |   ||  `- Re: VMS Cobol - GnuCOBOLArne Vajhøj
||  |   |`- Re: VMS Cobol - GnuCOBOLDenys Beauchemin
||  |   `* Re: VMS Cobol - GnuCOBOLArne Vajhøj
||  |    `* Re: VMS Cobol - GnuCOBOLDenys Beauchemin
||  |     `- Re: VMS Cobol - GnuCOBOLArne Vajhøj
||  `* Re: VMS Cobol - GnuCOBOLultr...@gmail.com
||   `* Re: VMS Cobol - GnuCOBOLSimon Clubley
||    +- Re: VMS Cobol - GnuCOBOLDave Froble
||    `* Re: VMS Cobol - GnuCOBOLultr...@gmail.com
||     +- Re: VMS Cobol - GnuCOBOLBob Eager
||     `* Re: VMS Cobol - GnuCOBOLSimon Clubley
||      +* Re: VMS Cobol - GnuCOBOLultr...@gmail.com
||      |+* Re: VMS Cobol - GnuCOBOLArne Vajhøj
||      ||+* Re: VMS Cobol - GnuCOBOLNeil Rieck
||      |||`- Re: VMS Cobol - GnuCOBOLArne Vajhøj
||      ||`* Re: VMS Cobol - GnuCOBOLArne Vajhøj
||      || `* Re: VMS Cobol - GnuCOBOLDenys Beauchemin
||      ||  +* Re: VMS Cobol - GnuCOBOLbill
||      ||  |`- Re: VMS Cobol - GnuCOBOLDenys Beauchemin
||      ||  `* Re: VMS Cobol - GnuCOBOLNeil Rieck
||      ||   +- Re: VMS Cobol - GnuCOBOLArne Vajhøj
||      ||   +- Re: VMS Cobol - GnuCOBOLDan Cross
||      ||   `* Re: VMS Cobol - GnuCOBOLJohnny Billquist
||      ||    `* Re: VMS Cobol - GnuCOBOLbill
||      ||     +* Re: VMS Cobol - GnuCOBOLDennis Boone
||      ||     |`- Re: VMS Cobol - GnuCOBOLbill
||      ||     +* Re: VMS Cobol - GnuCOBOLArne Vajhøj
||      ||     |`- Re: VMS Cobol - GnuCOBOLArne Vajhøj
||      ||     `* Re: VMS Cobol - GnuCOBOLArne Vajhøj
||      ||      +* Re: VMS Cobol - GnuCOBOLDave Froble
||      ||      |+- Re: VMS Cobol - GnuCOBOLArne Vajhøj
||      ||      |`* Re: VMS Cobol - GnuCOBOLbill
||      ||      | `- Re: VMS Cobol - GnuCOBOLArne Vajhøj
||      ||      +- Re: VMS Cobol - GnuCOBOLArne Vajhøj
||      ||      `* Re: VMS Cobol - GnuCOBOLScott Dorsey
||      ||       `* Re: VMS Cobol - GnuCOBOLDave Froble
||      ||        `* Re: VMS Cobol - GnuCOBOLArne Vajhøj
||      ||         `* Re: VMS Cobol - GnuCOBOLbill
||      ||          `* Re: VMS Cobol - GnuCOBOLArne Vajhøj
||      ||           `* Re: VMS Cobol - GnuCOBOLDave Froble
||      ||            `- Re: VMS Cobol - GnuCOBOLArne Vajhøj
||      |`* Re: VMS Cobol - GnuCOBOLSimon Clubley
||      | +* Re: VMS Cobol - GnuCOBOLNeil Rieck
||      | |`* Re: VMS Cobol - GnuCOBOLArne Vajhøj
||      | | +* Re: VMS Cobol - GnuCOBOLScott Dorsey
||      | | |+* Re: VMS Cobol - GnuCOBOLArne Vajhøj
||      | | ||`* Re: VMS Cobol - GnuCOBOLArne Vajhøj
||      | | || `- Re: VMS Cobol - GnuCOBOLSimon Clubley
||      | | |`* Re: VMS Cobol - GnuCOBOLSimon Clubley
||      | | | +- Re: VMS Cobol - GnuCOBOLArne Vajhøj
||      | | | `- Re: VMS Cobol - GnuCOBOLDennis Boone
||      | | `* Re: VMS Cobol - GnuCOBOLArne Vajhøj
||      | |  `- Re: VMS Cobol - GnuCOBOLMark DeArman
||      | +* Re: VMS Cobol - GnuCOBOLultr...@gmail.com
||      | |+- Re: VMS Cobol - GnuCOBOLSingle Stage to Orbit
||      | |`- Re: VMS Cobol - GnuCOBOLArne Vajhøj
||      | `* Re: VMS Cobol - GnuCOBOLultr...@gmail.com
||      |  +- Re: VMS Cobol - GnuCOBOLDave Froble
||      |  `- Re: VMS Cobol - GnuCOBOLArne Vajhøj
||      `* Re: VMS Cobol - GnuCOBOLultr...@gmail.com
||       `* Re: VMS Cobol - GnuCOBOLPaul Gavin
||        `* Re: VMS Cobol - GnuCOBOLultr...@gmail.com
||         +- Re: VMS Cobol - GnuCOBOLChris Townley
||         `* Re: VMS Cobol - GnuCOBOLArne Vajhøj
||          `* Re: VMS Cobol - GnuCOBOLDavid Wade
||           +- Re: VMS Cobol - GnuCOBOLScott Dorsey
||           `* Re: VMS Cobol - GnuCOBOLArne Vajhøj
||            +* Re: VMS Cobol - GnuCOBOLRobert A. Brooks
||            |+* Re: VMS Cobol - GnuCOBOLJohn Reagan
||            ||+- Re: VMS Cobol - GnuCOBOLDan Cross
||            ||+* Re: VMS Cobol - GnuCOBOLArne Vajhøj
||            |||`* Re: VMS Cobol - GnuCOBOLCraig A. Berry
||            ||| `* Re: VMS Cobol - GnuCOBOLJohn Reagan
||            |||  `- Re: VMS Cobol - GnuCOBOLAndreas Gruhl
||            ||`* Re: VMS Cobol - GnuCOBOLScott Dorsey
||            || +* Re: VMS Cobol - GnuCOBOLbill
||            || |`* Re: VMS Cobol - GnuCOBOLScott Dorsey
||            || | `* Re: VMS Cobol - GnuCOBOLJohnny Billquist
||            || |  `- Re: VMS Cobol - GnuCOBOLbill
||            || `- Re: VMS Cobol - GnuCOBOLArne Vajhøj
||            |`* Re: VMS Cobol - GnuCOBOLDenys Beauchemin
||            | `* Re: VMS Cobol - GnuCOBOLbill
||            |  `* Re: VMS Cobol - GnuCOBOLJohnny Billquist
||            |   +- Re: VMS Cobol - GnuCOBOLScott Dorsey
||            |   +- Re: VMS Cobol - GnuCOBOLbill
||            |   `* Re: VMS Cobol - GnuCOBOLplugh
||            `* Re: VMS Cobol - GnuCOBOLDavid Wade
|`* Re: VMS Cobol - GnuCOBOLDave Froble
`- Re: VMS Cobol - GnuCOBOLArne Vajhøj

Pages:123456
Re: VMS Cobol - GnuCOBOL

<ttm5bq$3o25o$1@dont-email.me>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=27020&group=comp.os.vms#27020

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: arn...@vajhoej.dk (Arne Vajhøj)
Newsgroups: comp.os.vms
Subject: Re: VMS Cobol - GnuCOBOL
Date: Tue, 28 Feb 2023 19:13:45 -0500
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <ttm5bq$3o25o$1@dont-email.me>
References: <tsbev9$1rela$2@dont-email.me>
<f01d95ad-13dd-4a1a-a798-c3c68d500879n@googlegroups.com>
<6e3f1442-707a-41a6-9292-62f14fbe73d
<199e3e7c-d1b1-4726-be39-2500b1e08851n@googlegroups.com>
<ttm3bq$4bq$1@panix2.panix.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 1 Mar 2023 00:13:46 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="ad44ca31bae8df472d1346664efd8bd8";
logging-data="3934392"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/nTBFHLHO/vs7VFC664Edo0gPzOyjWmSk="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Cancel-Lock: sha1:GzPnctStCKa6VewIARVe0NO7B6k=
In-Reply-To: <ttm3bq$4bq$1@panix2.panix.com>
Content-Language: en-US
 by: Arne Vajhøj - Wed, 1 Mar 2023 00:13 UTC

On 2/28/2023 6:39 PM, Scott Dorsey wrote:
> John Reagan <xyzzy1959@gmail.com> wrote:
>> Debugging optimized code has been the Holy Grail for years. On Alpha, GEM =
>> and the debugger have
>> some attempt at make it possible but it wasn't perfect. Later DWARF standa=
>> rds have added additional
>> features for compilers to use to help convey the transformations used by th=
>> e compiler, but it still a
>> challenge to present to the human in a way that makes sense. And of course=
>> , if the original source
>> program was technically illegal (which might be why you are in the debugger=
>> to start with), optimizers
>> will often do unspeakable transformations to such invalid programs. =20
>
> gus baird always said "You don't need a debugger. What you need is to stop
> putting bugs in your programs."

And Dijkstra said:

"If debugging is the process of removing software bugs, then programming
must be the process of putting them in."

But we live in the real world.

The old rule of thumb says 1 bug per 1000 LOC. So 50 MLOC means
50000 bugs.

Arne

Re: VMS Cobol - GnuCOBOL

<ttm8jp$11o$1@panix2.panix.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=27021&group=comp.os.vms#27021

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.panix2.panix.com!panix2.panix.com!not-for-mail
From: klu...@panix.com (Scott Dorsey)
Newsgroups: comp.os.vms
Subject: Re: VMS Cobol - GnuCOBOL
Date: 1 Mar 2023 01:09:13 -0000
Organization: Former users of Netcom shell (1989-2000)
Lines: 14
Message-ID: <ttm8jp$11o$1@panix2.panix.com>
References: <tsbev9$1rela$2@dont-email.me> <199e3e7c-d1b1-4726-be39-2500b1e08851n@googlegroups.com> <ttm3bq$4bq$1@panix2.panix.com> <k67ifaFu2e4U1@mid.individual.net>
Injection-Info: reader2.panix.com; posting-host="panix2.panix.com:166.84.1.2";
logging-data="5020"; mail-complaints-to="abuse@panix.com"
 by: Scott Dorsey - Wed, 1 Mar 2023 01:09 UTC

bill <bill.gunshannon@gmail.com> wrote:
>On 2/28/2023 6:39 PM, Scott Dorsey wrote:
>>
>>
>> gus baird always said "You don't need a debugger. What you need is to stop
>> putting bugs in your programs."
>
>Which is great if it is you putting the bugs in and not the compiler.

True. But unfortunately if the compiler is putting the bugs in, the debugger
is probably not of much use anyway.
--scott
--
"C'est un Nagra. C'est suisse, et tres, tres precis."

Re: VMS Cobol - GnuCOBOL

<7da8079a-ee1a-48b7-953c-365496067388n@googlegroups.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=27023&group=comp.os.vms#27023

  copy link   Newsgroups: comp.os.vms
X-Received: by 2002:ac8:1e8a:0:b0:3bf:cd6b:88e8 with SMTP id c10-20020ac81e8a000000b003bfcd6b88e8mr1387131qtm.12.1677660424376;
Wed, 01 Mar 2023 00:47:04 -0800 (PST)
X-Received: by 2002:ac8:4282:0:b0:3bf:d798:8ca7 with SMTP id
o2-20020ac84282000000b003bfd7988ca7mr1635473qtl.0.1677660424236; Wed, 01 Mar
2023 00:47:04 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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.os.vms
Date: Wed, 1 Mar 2023 00:47:03 -0800 (PST)
In-Reply-To: <bcc8746f-3cb3-428e-87fc-9388531d8613n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=217.91.122.53; posting-account=rjF0WAoAAAC39hl8XmA2ge39LAbz78Ru
NNTP-Posting-Host: 217.91.122.53
References: <tsbev9$1rela$2@dont-email.me> <eeb3774a-0294-4ed5-898e-bd0c72fe1de3n@googlegroups.com>
<k59m6uFtd0mU3@mid.individual.net> <tso8ao$3lki6$1@dont-email.me>
<tsohea$3mmd3$2@dont-email.me> <6de796f8-4945-490f-8d4b-1c1eb2b89430n@googlegroups.com>
<tt540k$1h5ki$1@dont-email.me> <8e93cec3-43ad-40a6-a788-0ed7c6582b0en@googlegroups.com>
<tt7oaq$1sfgf$1@dont-email.me> <aa422bc8-f141-4f4b-96a4-b57a80629c83n@googlegroups.com>
<f01d95ad-13dd-4a1a-a798-c3c68d500879n@googlegroups.com> <6e3f1442-707a-41a6-9292-62f14fbe73d1n@googlegroups.com>
<ttj5hc$3bob4$1@dont-email.me> <ttjbk4$3brol$1@dont-email.me>
<ttjeoa$3clbm$1@dont-email.me> <ttjkbv$3bhe9$1@dont-email.me>
<199e3e7c-d1b1-4726-be39-2500b1e08851n@googlegroups.com> <ttlams$3ku9o$2@dont-email.me>
<ttlk13$3m9l1$1@dont-email.me> <bcc8746f-3cb3-428e-87fc-9388531d8613n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7da8079a-ee1a-48b7-953c-365496067388n@googlegroups.com>
Subject: Re: VMS Cobol - GnuCOBOL
From: gru...@isidata.de (Andreas Gruhl)
Injection-Date: Wed, 01 Mar 2023 08:47:04 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 4022
 by: Andreas Gruhl - Wed, 1 Mar 2023 08:47 UTC

John Reagan schrieb am Dienstag, 28. Februar 2023 um 21:16:56 UTC+1:
> On Tuesday, February 28, 2023 at 2:17:58 PM UTC-5, Craig A. Berry wrote:
> > On 2/28/23 10:38 AM, Arne Vajhøj wrote:
> > > On 2/27/2023 10:35 PM, John Reagan wrote:
> > >> By the way, thanks to all the folks who've beat up on the native C
> > >> compiler so far. And while we've
> > >> been discussing these fine topics here on c.o.v, the native Fortran
> > >> compiler is about to appear. :)
> > >
> > > So C, C++ and Fortran are out (I have seen questions related to both C
> > > and C++).
> > >
> > > Cobol, Pascal and Basic to go. In that order? Maybe 3 months a piece?
> > Your guess is probably better than mine, but don't forget these are
> > field test releases and it's probably the same people fixing things in
> > existing compilers and working on the new ones. There might be a pause
> > where they fix all the gem2ir stuff that has come up with C and Fortran
> > before moving on to the other compilers. But then hopefully the later
> > compilers will be easier because more problems with the underpinnings
> > have already been shaken out.
> Not sure on the cadence. And yes, we're shaking things out right now especially
> with regards to debugging information, impact on optimizations (we're still working
> in that area), etc. I'll point out that the frontend for the Fortran compiler (written in C)
> is compiled on OpenVMS x86 with the native C compiler. We're "eating our own
> dogfood" as it were. And yes, we have native BLISS compilers too.
>
> I sure hope I don't accidentally cut-n-paste into the wrong window...
>
> PASCAL$ write sys$output f$getsyi("arch_name")
> x86_64
> PASCAL$ pascal/vers
> VSI Pascal x86-64 X6.3-136 (50X2D) on OpenVMS x86-64 V9.2
> PASCAL$ pascal hw
> PASCAL$ link hw
> PASCAL$ run hw
> hello world 10
> PASCAL$
Hey, that looks great. Please give me more.
Andreas

Re: VMS Cobol - GnuCOBOL

<ttnjhf$lg5$1@news.misty.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=27025&group=comp.os.vms#27025

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!1.us.feeder.erje.net!feeder.erje.net!news.misty.com!.POSTED.185.159.157.200!not-for-mail
From: bqt...@softjar.se (Johnny Billquist)
Newsgroups: comp.os.vms
Subject: Re: VMS Cobol - GnuCOBOL
Date: Wed, 1 Mar 2023 14:21:50 +0100
Organization: MGT Consulting
Message-ID: <ttnjhf$lg5$1@news.misty.com>
References: <tsbev9$1rela$2@dont-email.me>
<eeb3774a-0294-4ed5-898e-bd0c72fe1de3n@googlegroups.com>
<k59m6uFtd0mU3@mid.individual.net> <tso8ao$3lki6$1@dont-email.me>
<tsohea$3mmd3$2@dont-email.me>
<6de796f8-4945-490f-8d4b-1c1eb2b89430n@googlegroups.com>
<tt540k$1h5ki$1@dont-email.me>
<8e93cec3-43ad-40a6-a788-0ed7c6582b0en@googlegroups.com>
<tt7oaq$1sfgf$1@dont-email.me>
<aa422bc8-f141-4f4b-96a4-b57a80629c83n@googlegroups.com>
<f01d95ad-13dd-4a1a-a798-c3c68d500879n@googlegroups.com>
<6e3f1442-707a-41a6-9292-62f14fbe73d1n@googlegroups.com>
<ttj5hc$3bob4$1@dont-email.me> <ttjbk4$3brol$1@dont-email.me>
<ttjeoa$3clbm$1@dont-email.me> <ttjkbv$3bhe9$1@dont-email.me>
<be08c3cc-3990-401b-97d1-2cdf4ad92484n@googlegroups.com>
<k66td3Ftd0mU11@mid.individual.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 1 Mar 2023 13:21:51 -0000 (UTC)
Injection-Info: news.misty.com; posting-host="185.159.157.200";
logging-data="22021"; mail-complaints-to="abuse@misty.com"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.8.0
Content-Language: en-US
In-Reply-To: <k66td3Ftd0mU11@mid.individual.net>
 by: Johnny Billquist - Wed, 1 Mar 2023 13:21 UTC

On 2023-02-28 18:53, bill wrote:
> On 2/28/2023 12:04 PM, Denys Beauchemin wrote:
>> On Monday, February 27, 2023 at 7:11:36 PM UTC-6, Robert A. Brooks wrote:
>>> On 2/27/2023 6:35 PM, Arne Vajhøj wrote:
>>>
>>>> But isn't that the case for all VMS compilers? I know
>>>> I use /DEB/NOOP for both Fortran, Pascal and C when I want
>>>> to debug.
>>> Reagan may weigh in here, but I'm pretty sure that DEC suggested using
>>> /DEBUG/NOOP when using the debugger for any language with an
>>> optimizer back in
>>> the 80's; if so, then that's been a pretty consistent message.
>>>
>>> --
>>>
>>> --- Rob
>> Speaking of debuggers.
>>
>> I'm not clear on how you can actually debug a gnucobol program, since
>> it's C in reality.
>
> To be honest, there probably isn't really a debugger for GnuCOBOL.
> We really need to put this one misconception to rest.  You are not
> supposed to do anything with the C code generated by the GnuCOBOL
> compiler.  It's an intermediate language not intended for human
> consumption.  Every compiler I have worked with so far takes the
> original source and converts it into some intermediate language.
> Some use RTL.  Some use assembler.  GnuCOBOL uses C.  RATFOR uses
> Fortran.  :-)  We even have the Chung/Yuen Tiny Pascal which converted
> to a P-code that could be further processed into 8080 Assembler and
> then further processed into an executable for the Northstar.
> None of these intended humans to read, understand or manipulate
> the intermediate forms.  So lets just ignore the fact that GnuCOBOL
> converts COBOL into C.  It really converts COBOL into an executable
> program on the host computer just like every other compiler.

All very true. But that does not change the fact that when you point a
debugger at it, it will trace the binary back to C, not Cobol, unless
you extend the debugger to do the reversing of the C to the original
Cobol code. And unless you do some tricks to the C compiler, a debugger
don't even have a way to know that it wasn't originally C code.

But it is the same kind of problems all those other languages also have,
and in fact even native compiled languages. After all, the debugger only
sees the machine code, and hopefully a bunch of symbols and other
meta-data the compiler left behind.

Johnny

Re: VMS Cobol - GnuCOBOL

<ttnk0m$lg5$2@news.misty.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=27026&group=comp.os.vms#27026

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!.POSTED.185.159.157.200!not-for-mail
From: bqt...@softjar.se (Johnny Billquist)
Newsgroups: comp.os.vms
Subject: Re: VMS Cobol - GnuCOBOL
Date: Wed, 1 Mar 2023 14:29:58 +0100
Organization: MGT Consulting
Message-ID: <ttnk0m$lg5$2@news.misty.com>
References: <tsbev9$1rela$2@dont-email.me> <ttjeoa$3clbm$1@dont-email.me>
<ttkp6c$3jcuo$1@dont-email.me> <k66d38Ftd0kU10@mid.individual.net>
<ttljkd$668$1@reader2.panix.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 1 Mar 2023 13:29:58 -0000 (UTC)
Injection-Info: news.misty.com; posting-host="185.159.157.200";
logging-data="22021"; mail-complaints-to="abuse@misty.com"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.8.0
Content-Language: en-US
In-Reply-To: <ttljkd$668$1@reader2.panix.com>
 by: Johnny Billquist - Wed, 1 Mar 2023 13:29 UTC

On 2023-02-28 20:11, Dan Cross wrote:
> In article <k66d38Ftd0kU10@mid.individual.net>,
> bill <bill.gunshannon@gmail.com> wrote:
>>> Of course, BUT I feel other languages have fewer places where undefined
>>> behaviour can occur, and so the problem is not so severe.
>>>
>>
>> And then you have the case (it's been a long while but at one time
>> was very common in my experience) where turning off optimization
>> "fixes" the problem.
>
> Indeed; this is quite common. In the context of C and C++, this
> is often a result of misunderstanding how "undefined behavior"
> works. What UB actually means is that the language _imposes no
> requirements_ when such behavior is detected (C11, sec 3.4.3).
> So the compiler is free to implement any behavior it chooses.
>
> The issue is that compiler writers have begun taking aggressive
> advantage of this to use UB to push occasionally surprising
> optimizations.
>
> Consider, for example, this segment of code:
>
> unsigned short
> mul(unsigned short a, unsigned short b)
> {
> return a * b;
> }
>
> Is this always well-defined? Well, no, depending on the
> platform. But why? It looks innocuous enough.
>
> To understand this, consider a platform with 32-bit ints and
> 16-bit shorts. According to pretty much every version of the C
> standard, before the multiplication is performed, the operands
> will be subject to the, "usual arithmetic conversions" (C11 sec
> 6.3.1.8). In this case, the `unsigned short` operands have
> lesser "rank" than `int`, and an `int` can represent the full
> range of values representable in `unsigned short`, so the
> "integer promotions" apply and the operands will be converted to
> type `int` (C11 sec 6.3.1.1, para 2). The multiplication will
> then be performed using _signed_ integer arithemtic. But note
> that there exist unsigned 16-bit short values 'c' and 'd' such
> that 'c * d' overflows a signed 32-bit int, and non-atomic
> _signed_ integer overflow is undefined behavior in C (C11 sec
> 6.5 para 5; in this case, the product is not in the range of
> representable values for type `int`).
>
> The result is that the compiler is free to do whatever it wants
> here. In practical terms, most compilers will produce code that
> behaves as expected, but if a compiler decided to, for whatever
> reason, emitting (say) a saturating multiplication instruction
> instead of a a normal MUL, it would be entirely within its
> rights to do so. Caveat emptor.
>
> An issue with C code in particular is that it's almost
> impossible to write a non-trivial program that doesn't have
> _some_ UB in it, often hidden in ways that are not obvious to
> the programmer (e.g., inside of a macro perhaps). So as
> compilers evolve and become more aggressive, code that seems to
> have worked for _years_ all of a sudden seems to spontaneously
> break. Again, caveat emptor.
>
> So yeah. Often turning off the optimizer appears to "fix"
> programs. Heisenbugs indeed!

You overcomplicated the whole explanation.
Basically, if you multiply two numbers, and the result would be bigger
than the types involved, the result is undefined. In this case, the type
is unsigned short. If the multiplication cause anything that don't fit
into an unsigned short, then the result is undefined.

And it's fairly easy to find two unsigned short numbers that when
multiplied will give a result that don't fit into an unsigned short.

It's really not that different from any other language. Some languages
will throw an exception, others will just give some result that might or
might not be meaningful. But there is no guarantee in almost any
language of some kind of specific meaningful result. Try it in FORTRAN
and see what you get there, or Cobol (or BASIC). :-)

Johnny

Re: VMS Cobol - GnuCOBOL

<ttnk3p$lg5$3@news.misty.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=27027&group=comp.os.vms#27027

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!.POSTED.185.159.157.200!not-for-mail
From: bqt...@softjar.se (Johnny Billquist)
Newsgroups: comp.os.vms
Subject: Re: VMS Cobol - GnuCOBOL
Date: Wed, 1 Mar 2023 14:31:37 +0100
Organization: MGT Consulting
Message-ID: <ttnk3p$lg5$3@news.misty.com>
References: <tsbev9$1rela$2@dont-email.me>
<199e3e7c-d1b1-4726-be39-2500b1e08851n@googlegroups.com>
<ttm3bq$4bq$1@panix2.panix.com> <k67ifaFu2e4U1@mid.individual.net>
<ttm8jp$11o$1@panix2.panix.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 1 Mar 2023 13:31:37 -0000 (UTC)
Injection-Info: news.misty.com; posting-host="185.159.157.200";
logging-data="22021"; mail-complaints-to="abuse@misty.com"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.8.0
Content-Language: en-US
In-Reply-To: <ttm8jp$11o$1@panix2.panix.com>
 by: Johnny Billquist - Wed, 1 Mar 2023 13:31 UTC

On 2023-03-01 02:09, Scott Dorsey wrote:
> bill <bill.gunshannon@gmail.com> wrote:
>> On 2/28/2023 6:39 PM, Scott Dorsey wrote:
>>>
>>>
>>> gus baird always said "You don't need a debugger. What you need is to stop
>>> putting bugs in your programs."
>>
>> Which is great if it is you putting the bugs in and not the compiler.
>
> True. But unfortunately if the compiler is putting the bugs in, the debugger
> is probably not of much use anyway.

Depends. I've found one case of a gcc bug where a debugger showed the
problem just fine.

However, the statement can be applied recursively to the compiler as
well. Stop putting bugs in the compiler.

Johnny

Re: VMS Cobol - GnuCOBOL

<ttnlh8$ih3$1@panix2.panix.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=27028&group=comp.os.vms#27028

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.panix2.panix.com!panix2.panix.com!not-for-mail
From: klu...@panix.com (Scott Dorsey)
Newsgroups: comp.os.vms
Subject: Re: VMS Cobol - GnuCOBOL
Date: 1 Mar 2023 13:55:52 -0000
Organization: Former users of Netcom shell (1989-2000)
Lines: 24
Message-ID: <ttnlh8$ih3$1@panix2.panix.com>
References: <tsbev9$1rela$2@dont-email.me> <f01d95ad-13dd-4a1a-a798-c3c68d500879n@googlegroups.com> <6e3f1442-707a-41a6-9292-62f14fbe73d <ttnjhf$lg5$1@news.misty.com>
Injection-Info: reader2.panix.com; posting-host="panix2.panix.com:166.84.1.2";
logging-data="34"; mail-complaints-to="abuse@panix.com"
 by: Scott Dorsey - Wed, 1 Mar 2023 13:55 UTC

Johnny Billquist <bqt@softjar.se> wrote:
>All very true. But that does not change the fact that when you point a
>debugger at it, it will trace the binary back to C, not Cobol, unless
>you extend the debugger to do the reversing of the C to the original
>Cobol code. And unless you do some tricks to the C compiler, a debugger
>don't even have a way to know that it wasn't originally C code.

Doesn't gnucobol do that? I thought gdb did that just fine.

The original g77 used the Bell Labs f2c translator in front of gcc and
it often didn't work very well and debugging was occasionally an adventure
but it was better than you'd ever expect. Not that I was not delighted when
the natrive gfortran compiler finally came out.

>But it is the same kind of problems all those other languages also have,
>and in fact even native compiled languages. After all, the debugger only
>sees the machine code, and hopefully a bunch of symbols and other
>meta-data the compiler left behind.

When you have a precompiler and a compiler then you have twice as many
places for bugs to exist.
--scott
--
"C'est un Nagra. C'est suisse, et tres, tres precis."

Re: VMS Cobol - GnuCOBOL

<ttnov2$7l7$1@reader2.panix.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=27030&group=comp.os.vms#27030

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
From: cro...@spitfire.i.gajendra.net (Dan Cross)
Newsgroups: comp.os.vms
Subject: Re: VMS Cobol - GnuCOBOL
Date: Wed, 1 Mar 2023 14:54:26 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <ttnov2$7l7$1@reader2.panix.com>
References: <tsbev9$1rela$2@dont-email.me> <k66d38Ftd0kU10@mid.individual.net> <ttljkd$668$1@reader2.panix.com> <ttnk0m$lg5$2@news.misty.com>
Injection-Date: Wed, 1 Mar 2023 14:54:26 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
logging-data="7847"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)
 by: Dan Cross - Wed, 1 Mar 2023 14:54 UTC

In article <ttnk0m$lg5$2@news.misty.com>,
Johnny Billquist <bqt@softjar.se> wrote:
>On 2023-02-28 20:11, Dan Cross wrote:
>> In article <k66d38Ftd0kU10@mid.individual.net>,
>> bill <bill.gunshannon@gmail.com> wrote:
>>>> Of course, BUT I feel other languages have fewer places where undefined
>>>> behaviour can occur, and so the problem is not so severe.
>>>>
>>>
>>> And then you have the case (it's been a long while but at one time
>>> was very common in my experience) where turning off optimization
>>> "fixes" the problem.
>>
>> Indeed; this is quite common. In the context of C and C++, this
>> is often a result of misunderstanding how "undefined behavior"
>> works. What UB actually means is that the language _imposes no
>> requirements_ when such behavior is detected (C11, sec 3.4.3).
>> So the compiler is free to implement any behavior it chooses.
>>
>> The issue is that compiler writers have begun taking aggressive
>> advantage of this to use UB to push occasionally surprising
>> optimizations.
>>
>> Consider, for example, this segment of code:
>>
>> unsigned short
>> mul(unsigned short a, unsigned short b)
>> {
>> return a * b;
>> }
>>
>> Is this always well-defined? Well, no, depending on the
>> platform. But why? It looks innocuous enough.
>>
>> To understand this, consider a platform with 32-bit ints and
>> 16-bit shorts. According to pretty much every version of the C
>> standard, before the multiplication is performed, the operands
>> will be subject to the, "usual arithmetic conversions" (C11 sec
>> 6.3.1.8). In this case, the `unsigned short` operands have
>> lesser "rank" than `int`, and an `int` can represent the full
>> range of values representable in `unsigned short`, so the
>> "integer promotions" apply and the operands will be converted to
>> type `int` (C11 sec 6.3.1.1, para 2). The multiplication will
>> then be performed using _signed_ integer arithemtic. But note
>> that there exist unsigned 16-bit short values 'c' and 'd' such
>> that 'c * d' overflows a signed 32-bit int, and non-atomic
>> _signed_ integer overflow is undefined behavior in C (C11 sec
>> 6.5 para 5; in this case, the product is not in the range of
>> representable values for type `int`).
>>
>> The result is that the compiler is free to do whatever it wants
>> here. In practical terms, most compilers will produce code that
>> behaves as expected, but if a compiler decided to, for whatever
>> reason, emitting (say) a saturating multiplication instruction
>> instead of a a normal MUL, it would be entirely within its
>> rights to do so. Caveat emptor.
>>
>> An issue with C code in particular is that it's almost
>> impossible to write a non-trivial program that doesn't have
>> _some_ UB in it, often hidden in ways that are not obvious to
>> the programmer (e.g., inside of a macro perhaps). So as
>> compilers evolve and become more aggressive, code that seems to
>> have worked for _years_ all of a sudden seems to spontaneously
>> break. Again, caveat emptor.
>>
>> So yeah. Often turning off the optimizer appears to "fix"
>> programs. Heisenbugs indeed!
>
>You overcomplicated the whole explanation.

Hmm.

>Basically, if you multiply two numbers, and the result would be bigger
>than the types involved, the result is undefined.

Well...no. _unsigned_ integer overflow in C is well-defined (it
has modular wrapping semantics; C11 sec 6.2.5 para 9).
Similarly, overflow of signed atomics is well-defined (C11 sec
7.17.7.5 para 3), so this is not always true.

>In this case, the type
>is unsigned short. If the multiplication cause anything that don't fit
>into an unsigned short, then the result is undefined.
>
>And it's fairly easy to find two unsigned short numbers that when
>multiplied will give a result that don't fit into an unsigned short.

The range of unsigned short has little to do with it, and
truncation of the result is fine too (again, defined to use
modular wrapping for unsigned types; C11 sec 6.3.1.3). The
problem is entirely due to the promotion to _signed_ int prior
to the multiplication. The fix, incidentally, is easy:

unsigned short
mul(unsigned short a, unsigned short b)
{ unsigned int aa = a, bb = b;
return aa * bb;
}

This is well-defined, even if the range of `unsigned short` is
the same as `unsigned int`, which is permitted by the standard.

>It's really not that different from any other language. Some languages
>will throw an exception, others will just give some result that might or
>might not be meaningful. But there is no guarantee in almost any
>language of some kind of specific meaningful result. Try it in FORTRAN
>and see what you get there, or Cobol (or BASIC). :-)

The issue, and the reason for the complex initial explanation,
is the subtle interaction between the implicit type promotion
rules, arithmetic, undefined behavior, and the freedom that UB
gives to compiler writers, which is pretty unique to C. Hence
why optimizing compilers often _appear_ to introduce bugs when
in fact they're performing perfectly legal transformations, and
turning off the optimizer can appear to "fix" the problem.

- Dan C.

Re: VMS Cobol - GnuCOBOL

<k69agdFu2e5U1@mid.individual.net>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=27031&group=comp.os.vms#27031

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: bill.gun...@gmail.com (bill)
Newsgroups: comp.os.vms
Subject: Re: VMS Cobol - GnuCOBOL
Date: Wed, 1 Mar 2023 10:49:33 -0500
Lines: 28
Message-ID: <k69agdFu2e5U1@mid.individual.net>
References: <tsbev9$1rela$2@dont-email.me>
<199e3e7c-d1b1-4726-be39-2500b1e08851n@googlegroups.com>
<ttm3bq$4bq$1@panix2.panix.com> <k67ifaFu2e4U1@mid.individual.net>
<ttm8jp$11o$1@panix2.panix.com> <ttnk3p$lg5$3@news.misty.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net LSit5erAoUU4VHzIq3ePJQTxelFSzQJ3oYg8K6qaWNOsBRExIA
Cancel-Lock: sha1:BBOSHm5gs32urN46yLSHzOpogRU=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Content-Language: en-US
In-Reply-To: <ttnk3p$lg5$3@news.misty.com>
 by: bill - Wed, 1 Mar 2023 15:49 UTC

On 3/1/2023 8:31 AM, Johnny Billquist wrote:
> On 2023-03-01 02:09, Scott Dorsey wrote:
>> bill  <bill.gunshannon@gmail.com> wrote:
>>> On 2/28/2023 6:39 PM, Scott Dorsey wrote:
>>>>
>>>>
>>>> gus baird always said "You don't need a debugger.  What you need is
>>>> to stop
>>>> putting bugs in your programs."
>>>
>>> Which is great if it is you putting the bugs in and not the compiler.
>>
>> True.  But unfortunately if the compiler is putting the bugs in, the
>> debugger
>> is probably not of much use anyway.
>
> Depends. I've found one case of a gcc bug where a debugger showed the
> problem just fine.
>
> However, the statement can be applied recursively to the compiler as
> well. Stop putting bugs in the compiler.

Or backdoors. :-)

bill

Re: VMS Cobol - GnuCOBOL

<k69hc8Fu2e5U2@mid.individual.net>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=27034&group=comp.os.vms#27034

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: bill.gun...@gmail.com (bill)
Newsgroups: comp.os.vms
Subject: Re: VMS Cobol - GnuCOBOL
Date: Wed, 1 Mar 2023 12:46:48 -0500
Lines: 57
Message-ID: <k69hc8Fu2e5U2@mid.individual.net>
References: <tsbev9$1rela$2@dont-email.me>
<eeb3774a-0294-4ed5-898e-bd0c72fe1de3n@googlegroups.com>
<k59m6uFtd0mU3@mid.individual.net> <tso8ao$3lki6$1@dont-email.me>
<tsohea$3mmd3$2@dont-email.me>
<6de796f8-4945-490f-8d4b-1c1eb2b89430n@googlegroups.com>
<tt540k$1h5ki$1@dont-email.me>
<8e93cec3-43ad-40a6-a788-0ed7c6582b0en@googlegroups.com>
<tt7oaq$1sfgf$1@dont-email.me>
<aa422bc8-f141-4f4b-96a4-b57a80629c83n@googlegroups.com>
<f01d95ad-13dd-4a1a-a798-c3c68d500879n@googlegroups.com>
<6e3f1442-707a-41a6-9292-62f14fbe73d1n@googlegroups.com>
<ttj5hc$3bob4$1@dont-email.me> <ttjbk4$3brol$1@dont-email.me>
<ttjeoa$3clbm$1@dont-email.me> <ttjkbv$3bhe9$1@dont-email.me>
<be08c3cc-3990-401b-97d1-2cdf4ad92484n@googlegroups.com>
<k66td3Ftd0mU11@mid.individual.net> <ttnjhf$lg5$1@news.misty.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net R4ltwZOmASrlnug6CnW6hwp3z1MrkYwOujWzUqn6QmSqe+iRL1
Cancel-Lock: sha1:1uNSQEDDLsi9VCCty4273/XAMp0=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Content-Language: en-US
In-Reply-To: <ttnjhf$lg5$1@news.misty.com>
 by: bill - Wed, 1 Mar 2023 17:46 UTC

On 3/1/2023 8:21 AM, Johnny Billquist wrote:
> On 2023-02-28 18:53, bill wrote:
>> On 2/28/2023 12:04 PM, Denys Beauchemin wrote:
>>> On Monday, February 27, 2023 at 7:11:36 PM UTC-6, Robert A. Brooks
>>> wrote:
>>>> On 2/27/2023 6:35 PM, Arne Vajhøj wrote:
>>>>
>>>>> But isn't that the case for all VMS compilers? I know
>>>>> I use /DEB/NOOP for both Fortran, Pascal and C when I want
>>>>> to debug.
>>>> Reagan may weigh in here, but I'm pretty sure that DEC suggested using
>>>> /DEBUG/NOOP when using the debugger for any language with an
>>>> optimizer back in
>>>> the 80's; if so, then that's been a pretty consistent message.
>>>>
>>>> --
>>>>
>>>> --- Rob
>>> Speaking of debuggers.
>>>
>>> I'm not clear on how you can actually debug a gnucobol program, since
>>> it's C in reality.
>>
>> To be honest, there probably isn't really a debugger for GnuCOBOL.
>> We really need to put this one misconception to rest.  You are not
>> supposed to do anything with the C code generated by the GnuCOBOL
>> compiler.  It's an intermediate language not intended for human
>> consumption.  Every compiler I have worked with so far takes the
>> original source and converts it into some intermediate language.
>> Some use RTL.  Some use assembler.  GnuCOBOL uses C.  RATFOR uses
>> Fortran.  :-)  We even have the Chung/Yuen Tiny Pascal which converted
>> to a P-code that could be further processed into 8080 Assembler and
>> then further processed into an executable for the Northstar.
>> None of these intended humans to read, understand or manipulate
>> the intermediate forms.  So lets just ignore the fact that GnuCOBOL
>> converts COBOL into C.  It really converts COBOL into an executable
>> program on the host computer just like every other compiler.
>
> All very true. But that does not change the fact that when you point a
> debugger at it, it will trace the binary back to C, not Cobol, unless
> you extend the debugger to do the reversing of the C to the original
> Cobol code. And unless you do some tricks to the C compiler, a debugger
> don't even have a way to know that it wasn't originally C code.
>
> But it is the same kind of problems all those other languages also have,
> and in fact even native compiled languages. After all, the debugger only
> sees the machine code, and hopefully a bunch of symbols and other
> meta-data the compiler left behind.

Looks like COBOL is still stuck with
SOURCE-COMPUTER. source-computer-entry [WITH DEBUGGING MODE].

:-)

bill

Re: VMS Cobol - GnuCOBOL

<k69hofFu2e4U2@mid.individual.net>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=27035&group=comp.os.vms#27035

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: bill.gun...@gmail.com (bill)
Newsgroups: comp.os.vms
Subject: Re: VMS Cobol - GnuCOBOL
Date: Wed, 1 Mar 2023 12:53:19 -0500
Lines: 22
Message-ID: <k69hofFu2e4U2@mid.individual.net>
References: <tsbev9$1rela$2@dont-email.me> <ttjeoa$3clbm$1@dont-email.me>
<ttkp6c$3jcuo$1@dont-email.me> <k66d38Ftd0kU10@mid.individual.net>
<ttljkd$668$1@reader2.panix.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net +ITuVWzhNBYOyiPlWK0GvQcW2jEA7X2mPc0L1d3FvnmUk3NjdP
Cancel-Lock: sha1:Y6Si+gKTgcss/poBMDd8sQbu0UM=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Content-Language: en-US
In-Reply-To: <ttljkd$668$1@reader2.panix.com>
 by: bill - Wed, 1 Mar 2023 17:53 UTC

On 2/28/2023 2:11 PM, Dan Cross wrote:
>
>
> Consider, for example, this segment of code:
>
> unsigned short
> mul(unsigned short a, unsigned short b)
> {
> return a * b;
> }
>

I have always considered this to be really stupid code.
For the vast majority of values for a and b this is going to
overflow. That means that regardless of what "undefined behavior"
actually means the result will be useless.

What were we just saying about programmers not writing buggy code?

bill

Re: VMS Cobol - GnuCOBOL

<tto959$f4t$1@reader2.panix.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=27039&group=comp.os.vms#27039

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
From: cro...@spitfire.i.gajendra.net (Dan Cross)
Newsgroups: comp.os.vms
Subject: Re: VMS Cobol - GnuCOBOL
Date: Wed, 1 Mar 2023 19:30:49 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <tto959$f4t$1@reader2.panix.com>
References: <tsbev9$1rela$2@dont-email.me> <k66d38Ftd0kU10@mid.individual.net> <ttljkd$668$1@reader2.panix.com> <k69hofFu2e4U2@mid.individual.net>
Injection-Date: Wed, 1 Mar 2023 19:30:49 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
logging-data="15517"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)
 by: Dan Cross - Wed, 1 Mar 2023 19:30 UTC

In article <k69hofFu2e4U2@mid.individual.net>,
bill <bill.gunshannon@gmail.com> wrote:
>On 2/28/2023 2:11 PM, Dan Cross wrote:
>>
>>
>> Consider, for example, this segment of code:
>>
>> unsigned short
>> mul(unsigned short a, unsigned short b)
>> {
>> return a * b;
>> }
>
>I have always considered this to be really stupid code.
>For the vast majority of values for a and b this is going to
>overflow. That means that regardless of what "undefined behavior"
>actually means the result will be useless.

?? Sure, this is a contrived example, but what makes you think
that the original programmer didn't want the wrapping behavior
on overflow?

It's a contrived example, but having well-defined overflow
semantics is actually really useful; consider checksumming
and hashing functions. Or, for that matter, cryptographic
code (which often makes heavy use of modular arithmetic).

Yeah, this example is dumb, but there are plenty of similar
examples that are not. For example, consider this checksum:

unsigned char
checksum(const unsigned char *p, size_t n)
{ unsigned char c = 0;

for (size_t i = 0; i < n; i++)
c += *p++;

return 0 - c;
}

Is that well-defined? One may look at it and say, "yes, of
course; there's no way that the addition can overflow because
both 8-bit `unsigned char` operands will be converted to any
flavor of `int`, and that cannot overflow."

Except that there are implementations where the range of `int`
and `unsigned char` are the same, and on those, overflow _could_
occur.

So, one should, instead, write:

unsigned char
checksum(const unsigned char *p, size_t n)
{ unsigned int c = 0;

for (size_t i = 0; i < n; i++)
c += *p++;

return 0 - c;
}

Subtle, no?

>What were we just saying about programmers not writing buggy code?

Good luck with that. :-)

- Dan C.

Re: VMS Cobol - GnuCOBOL

<b72b2b0e-e19f-4763-bfee-5eb68c9735a7n@googlegroups.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=27054&group=comp.os.vms#27054

  copy link   Newsgroups: comp.os.vms
X-Received: by 2002:a05:620a:66d:b0:71f:b917:f4ec with SMTP id a13-20020a05620a066d00b0071fb917f4ecmr2058016qkh.15.1677762478585;
Thu, 02 Mar 2023 05:07:58 -0800 (PST)
X-Received: by 2002:a05:620a:6c2:b0:742:6f50:2444 with SMTP id
2-20020a05620a06c200b007426f502444mr2550340qky.13.1677762478260; Thu, 02 Mar
2023 05:07:58 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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.os.vms
Date: Thu, 2 Mar 2023 05:07:57 -0800 (PST)
In-Reply-To: <ttnjhf$lg5$1@news.misty.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2400:ddc0:c000:0:0:0:0:a04e;
posting-account=uNeudQoAAACm0ETOCzPNrvtq-73lRbuD
NNTP-Posting-Host: 2400:ddc0:c000:0:0:0:0:a04e
References: <tsbev9$1rela$2@dont-email.me> <eeb3774a-0294-4ed5-898e-bd0c72fe1de3n@googlegroups.com>
<k59m6uFtd0mU3@mid.individual.net> <tso8ao$3lki6$1@dont-email.me>
<tsohea$3mmd3$2@dont-email.me> <6de796f8-4945-490f-8d4b-1c1eb2b89430n@googlegroups.com>
<tt540k$1h5ki$1@dont-email.me> <8e93cec3-43ad-40a6-a788-0ed7c6582b0en@googlegroups.com>
<tt7oaq$1sfgf$1@dont-email.me> <aa422bc8-f141-4f4b-96a4-b57a80629c83n@googlegroups.com>
<f01d95ad-13dd-4a1a-a798-c3c68d500879n@googlegroups.com> <6e3f1442-707a-41a6-9292-62f14fbe73d1n@googlegroups.com>
<ttj5hc$3bob4$1@dont-email.me> <ttjbk4$3brol$1@dont-email.me>
<ttjeoa$3clbm$1@dont-email.me> <ttjkbv$3bhe9$1@dont-email.me>
<be08c3cc-3990-401b-97d1-2cdf4ad92484n@googlegroups.com> <k66td3Ftd0mU11@mid.individual.net>
<ttnjhf$lg5$1@news.misty.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b72b2b0e-e19f-4763-bfee-5eb68c9735a7n@googlegroups.com>
Subject: Re: VMS Cobol - GnuCOBOL
From: jchim...@gmail.com (plugh)
Injection-Date: Thu, 02 Mar 2023 13:07:58 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3091
 by: plugh - Thu, 2 Mar 2023 13:07 UTC

On Wednesday, March 1, 2023 at 6:21:54 AM UTC-7, Johnny Billquist wrote:
> On 2023-02-28 18:53, bill wrote:
> > On 2/28/2023 12:04 PM, Denys Beauchemin wrote:
> >> On Monday, February 27, 2023 at 7:11:36 PM UTC-6, Robert A. Brooks wrote:
> >>> On 2/27/2023 6:35 PM, Arne Vajhøj wrote:
> >>>
> >>>> But isn't that the case for all VMS compilers? I know
> >>>> I use /DEB/NOOP for both Fortran, Pascal and C when I want
> >>>> to debug.
> >>> Reagan may weigh in here, but I'm pretty sure that DEC suggested using
> >>> /DEBUG/NOOP when using the debugger for any language with an
> >>> optimizer back in
> >>> the 80's; if so, then that's been a pretty consistent message.
> >>>
> >>> --
> >>>
> >>> --- Rob
> >> Speaking of debuggers.
> >>
> >> I'm not clear on how you can actually debug a gnucobol program, since
> >> it's C in reality.
<snip>
> Johnny

Speaking of debugging GnuCobol (nee open-cobol)
https://lists.gnu.org/archive/html/gnucobol-users/2009-06/msg00003.html
I can't say why I never followed up. Anyway, it looks like the problem's been solved in the meanwhile.

Re: VMS Cobol - GnuCOBOL

<36c6e7ae-1dce-4ee5-be0d-445cec65266bn@googlegroups.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=27055&group=comp.os.vms#27055

  copy link   Newsgroups: comp.os.vms
X-Received: by 2002:a05:620a:13c2:b0:73b:9bb4:1f68 with SMTP id g2-20020a05620a13c200b0073b9bb41f68mr2475831qkl.9.1677762854022;
Thu, 02 Mar 2023 05:14:14 -0800 (PST)
X-Received: by 2002:a05:620a:b0f:b0:742:7fb5:f516 with SMTP id
t15-20020a05620a0b0f00b007427fb5f516mr2347690qkg.1.1677762853789; Thu, 02 Mar
2023 05:14:13 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.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.os.vms
Date: Thu, 2 Mar 2023 05:14:13 -0800 (PST)
In-Reply-To: <b72b2b0e-e19f-4763-bfee-5eb68c9735a7n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2400:ddc0:c000:0:0:0:0:a04e;
posting-account=uNeudQoAAACm0ETOCzPNrvtq-73lRbuD
NNTP-Posting-Host: 2400:ddc0:c000:0:0:0:0:a04e
References: <tsbev9$1rela$2@dont-email.me> <eeb3774a-0294-4ed5-898e-bd0c72fe1de3n@googlegroups.com>
<k59m6uFtd0mU3@mid.individual.net> <tso8ao$3lki6$1@dont-email.me>
<tsohea$3mmd3$2@dont-email.me> <6de796f8-4945-490f-8d4b-1c1eb2b89430n@googlegroups.com>
<tt540k$1h5ki$1@dont-email.me> <8e93cec3-43ad-40a6-a788-0ed7c6582b0en@googlegroups.com>
<tt7oaq$1sfgf$1@dont-email.me> <aa422bc8-f141-4f4b-96a4-b57a80629c83n@googlegroups.com>
<f01d95ad-13dd-4a1a-a798-c3c68d500879n@googlegroups.com> <6e3f1442-707a-41a6-9292-62f14fbe73d1n@googlegroups.com>
<ttj5hc$3bob4$1@dont-email.me> <ttjbk4$3brol$1@dont-email.me>
<ttjeoa$3clbm$1@dont-email.me> <ttjkbv$3bhe9$1@dont-email.me>
<be08c3cc-3990-401b-97d1-2cdf4ad92484n@googlegroups.com> <k66td3Ftd0mU11@mid.individual.net>
<ttnjhf$lg5$1@news.misty.com> <b72b2b0e-e19f-4763-bfee-5eb68c9735a7n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <36c6e7ae-1dce-4ee5-be0d-445cec65266bn@googlegroups.com>
Subject: Re: VMS Cobol - GnuCOBOL
From: jchim...@gmail.com (plugh)
Injection-Date: Thu, 02 Mar 2023 13:14:14 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3360
 by: plugh - Thu, 2 Mar 2023 13:14 UTC

On Thursday, March 2, 2023 at 6:08:00 AM UTC-7, plugh wrote:
> On Wednesday, March 1, 2023 at 6:21:54 AM UTC-7, Johnny Billquist wrote:
> > On 2023-02-28 18:53, bill wrote:
> > > On 2/28/2023 12:04 PM, Denys Beauchemin wrote:
> > >> On Monday, February 27, 2023 at 7:11:36 PM UTC-6, Robert A. Brooks wrote:
> > >>> On 2/27/2023 6:35 PM, Arne Vajhøj wrote:
> > >>>
> > >>>> But isn't that the case for all VMS compilers? I know
> > >>>> I use /DEB/NOOP for both Fortran, Pascal and C when I want
> > >>>> to debug.
> > >>> Reagan may weigh in here, but I'm pretty sure that DEC suggested using
> > >>> /DEBUG/NOOP when using the debugger for any language with an
> > >>> optimizer back in
> > >>> the 80's; if so, then that's been a pretty consistent message.
> > >>>
> > >>> --
> > >>>
> > >>> --- Rob
> > >> Speaking of debuggers.
> > >>
> > >> I'm not clear on how you can actually debug a gnucobol program, since
> > >> it's C in reality.
> <snip>
> > Johnny
>
> Speaking of debugging GnuCobol (nee open-cobol)
> https://lists.gnu.org/archive/html/gnucobol-users/2009-06/msg00003.html
> I can't say why I never followed up. Anyway, it looks like the problem's been solved in the meanwhile.

Sorry, I think that was bill, not Johnny

Re: VMS Cobol - GnuCOBOL

<k6btpvFu2e4U4@mid.individual.net>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=27056&group=comp.os.vms#27056

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: bill.gun...@gmail.com (bill)
Newsgroups: comp.os.vms
Subject: Re: VMS Cobol - GnuCOBOL
Date: Thu, 2 Mar 2023 10:31:11 -0500
Lines: 37
Message-ID: <k6btpvFu2e4U4@mid.individual.net>
References: <tsbev9$1rela$2@dont-email.me>
<eeb3774a-0294-4ed5-898e-bd0c72fe1de3n@googlegroups.com>
<k59m6uFtd0mU3@mid.individual.net> <tso8ao$3lki6$1@dont-email.me>
<tsohea$3mmd3$2@dont-email.me>
<6de796f8-4945-490f-8d4b-1c1eb2b89430n@googlegroups.com>
<tt540k$1h5ki$1@dont-email.me>
<8e93cec3-43ad-40a6-a788-0ed7c6582b0en@googlegroups.com>
<tt7oaq$1sfgf$1@dont-email.me>
<aa422bc8-f141-4f4b-96a4-b57a80629c83n@googlegroups.com>
<f01d95ad-13dd-4a1a-a798-c3c68d500879n@googlegroups.com>
<6e3f1442-707a-41a6-9292-62f14fbe73d1n@googlegroups.com>
<ttj5hc$3bob4$1@dont-email.me> <ttjbk4$3brol$1@dont-email.me>
<ttjeoa$3clbm$1@dont-email.me> <ttjkbv$3bhe9$1@dont-email.me>
<be08c3cc-3990-401b-97d1-2cdf4ad92484n@googlegroups.com>
<k66td3Ftd0mU11@mid.individual.net> <ttnjhf$lg5$1@news.misty.com>
<b72b2b0e-e19f-4763-bfee-5eb68c9735a7n@googlegroups.com>
<36c6e7ae-1dce-4ee5-be0d-445cec65266bn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net yU5RaEWNMdk5FQ3MWvRCYwnybp/pz+HT8EUn6vapLCZLmjdOnz
Cancel-Lock: sha1:YE8E5vykwHJJYiHQSlQ7Qc5s4ZU=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Content-Language: en-US
In-Reply-To: <36c6e7ae-1dce-4ee5-be0d-445cec65266bn@googlegroups.com>
 by: bill - Thu, 2 Mar 2023 15:31 UTC

On 3/2/2023 8:14 AM, plugh wrote:
> On Thursday, March 2, 2023 at 6:08:00 AM UTC-7, plugh wrote:
>> On Wednesday, March 1, 2023 at 6:21:54 AM UTC-7, Johnny Billquist wrote:
>>> On 2023-02-28 18:53, bill wrote:
>>>> On 2/28/2023 12:04 PM, Denys Beauchemin wrote:
>>>>> On Monday, February 27, 2023 at 7:11:36 PM UTC-6, Robert A. Brooks wrote:
>>>>>> On 2/27/2023 6:35 PM, Arne Vajhøj wrote:
>>>>>>
>>>>>>> But isn't that the case for all VMS compilers? I know
>>>>>>> I use /DEB/NOOP for both Fortran, Pascal and C when I want
>>>>>>> to debug.
>>>>>> Reagan may weigh in here, but I'm pretty sure that DEC suggested using
>>>>>> /DEBUG/NOOP when using the debugger for any language with an
>>>>>> optimizer back in
>>>>>> the 80's; if so, then that's been a pretty consistent message.
>>>>>>
>>>>>> --
>>>>>>
>>>>>> --- Rob
>>>>> Speaking of debuggers.
>>>>>
>>>>> I'm not clear on how you can actually debug a gnucobol program, since
>>>>> it's C in reality.
>> <snip>
>>> Johnny
>>
>> Speaking of debugging GnuCobol (nee open-cobol)
>> https://lists.gnu.org/archive/html/gnucobol-users/2009-06/msg00003.html
>> I can't say why I never followed up. Anyway, it looks like the problem's been solved in the meanwhile.
>
> Sorry, I think that was bill, not Johnny

None of the included content was from me. Not sure if any of it was
from Johnny but I don't think so.

bill

Re: VMS Cobol - GnuCOBOL

<ttqfq7$c47$1@reader2.panix.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=27057&group=comp.os.vms#27057

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
From: cro...@spitfire.i.gajendra.net (Dan Cross)
Newsgroups: comp.os.vms
Subject: Re: VMS Cobol - GnuCOBOL
Date: Thu, 2 Mar 2023 15:36:39 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <ttqfq7$c47$1@reader2.panix.com>
References: <tsbev9$1rela$2@dont-email.me> <b72b2b0e-e19f-4763-bfee-5eb68c9735a7n@googlegroups.com> <36c6e7ae-1dce-4ee5-be0d-445cec65266bn@googlegroups.com> <k6btpvFu2e4U4@mid.individual.net>
Injection-Date: Thu, 2 Mar 2023 15:36:39 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
logging-data="12423"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)
 by: Dan Cross - Thu, 2 Mar 2023 15:36 UTC

In article <k6btpvFu2e4U4@mid.individual.net>,
bill <bill.gunshannon@gmail.com> wrote:
>On 3/2/2023 8:14 AM, plugh wrote:
>> On Thursday, March 2, 2023 at 6:08:00 AM UTC-7, plugh wrote:
>>> On Wednesday, March 1, 2023 at 6:21:54 AM UTC-7, Johnny Billquist wrote:
>>>> On 2023-02-28 18:53, bill wrote:
>>>>> On 2/28/2023 12:04 PM, Denys Beauchemin wrote:
>>>>>> On Monday, February 27, 2023 at 7:11:36 PM UTC-6, Robert A. Brooks wrote:
>>>>>>> On 2/27/2023 6:35 PM, Arne Vajhøj wrote:
>>>>>>>
>>>>>>>> But isn't that the case for all VMS compilers? I know
>>>>>>>> I use /DEB/NOOP for both Fortran, Pascal and C when I want
>>>>>>>> to debug.
>>>>>>> Reagan may weigh in here, but I'm pretty sure that DEC suggested using
>>>>>>> /DEBUG/NOOP when using the debugger for any language with an
>>>>>>> optimizer back in
>>>>>>> the 80's; if so, then that's been a pretty consistent message.
>>>>>>>
>>>>>>> --
>>>>>>>
>>>>>>> --- Rob
>>>>>> Speaking of debuggers.
>>>>>>
>>>>>> I'm not clear on how you can actually debug a gnucobol program, since
>>>>>> it's C in reality.
>>> <snip>
>>>> Johnny
>>>
>>> Speaking of debugging GnuCobol (nee open-cobol)
>>> https://lists.gnu.org/archive/html/gnucobol-users/2009-06/msg00003.html
>>> I can't say why I never followed up. Anyway, it looks like the problem's been solved in the meanwhile.
>>
>> Sorry, I think that was bill, not Johnny
>
>None of the included content was from me. Not sure if any of it was
>from Johnny but I don't think so.

The proximal content was from Denys Beauchemin in
<be08c3cc-3990-401b-97d1-2cdf4ad92484n@googlegroups.com>.

The ">>>> Johnny" thing appears to be a text editing error,
because the response was cutting from many levels of quotation
(responses to responses to...).

- Dan C.

Re: VMS Cobol - GnuCOBOL

<ttsne6$ro6$1@news.misty.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=27062&group=comp.os.vms#27062

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!.POSTED.185.159.157.200!not-for-mail
From: bqt...@softjar.se (Johnny Billquist)
Newsgroups: comp.os.vms
Subject: Re: VMS Cobol - GnuCOBOL
Date: Fri, 3 Mar 2023 12:59:02 +0100
Organization: MGT Consulting
Message-ID: <ttsne6$ro6$1@news.misty.com>
References: <tsbev9$1rela$2@dont-email.me> <k66d38Ftd0kU10@mid.individual.net>
<ttljkd$668$1@reader2.panix.com> <ttnk0m$lg5$2@news.misty.com>
<ttnov2$7l7$1@reader2.panix.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 3 Mar 2023 11:59:02 -0000 (UTC)
Injection-Info: news.misty.com; posting-host="185.159.157.200";
logging-data="28422"; mail-complaints-to="abuse@misty.com"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.8.0
Content-Language: en-US
In-Reply-To: <ttnov2$7l7$1@reader2.panix.com>
 by: Johnny Billquist - Fri, 3 Mar 2023 11:59 UTC

Damn! I learned something new today...

On 2023-03-01 15:54, Dan Cross wrote:
> In article <ttnk0m$lg5$2@news.misty.com>,
> Johnny Billquist <bqt@softjar.se> wrote:
>> On 2023-02-28 20:11, Dan Cross wrote:

[...]

>> You overcomplicated the whole explanation.
>
> Hmm.

I was wrong. :-)

>> Basically, if you multiply two numbers, and the result would be bigger
>> than the types involved, the result is undefined.
>
> Well...no. _unsigned_ integer overflow in C is well-defined (it
> has modular wrapping semantics; C11 sec 6.2.5 para 9).
> Similarly, overflow of signed atomics is well-defined (C11 sec
> 7.17.7.5 para 3), so this is not always true.

I had actually missed that unsigned integers do have a defined overflow
behavior. Thanks.

>> In this case, the type
>> is unsigned short. If the multiplication cause anything that don't fit
>> into an unsigned short, then the result is undefined.
>>
>> And it's fairly easy to find two unsigned short numbers that when
>> multiplied will give a result that don't fit into an unsigned short.
>
> The range of unsigned short has little to do with it, and
> truncation of the result is fine too (again, defined to use
> modular wrapping for unsigned types; C11 sec 6.3.1.3). The
> problem is entirely due to the promotion to _signed_ int prior
> to the multiplication. The fix, incidentally, is easy:
>
> unsigned short
> mul(unsigned short a, unsigned short b)
> {
> unsigned int aa = a, bb = b;
> return aa * bb;
> }
>
> This is well-defined, even if the range of `unsigned short` is
> the same as `unsigned int`, which is permitted by the standard.

Right. My second error. It is allowed to promote a unsigned short to a
signed int.
I do feel that I don't entirely agree with that rule, but it's
definitely written as such.

Changing from unsigned to signed feels just as a freedom too much.

>> It's really not that different from any other language. Some languages
>> will throw an exception, others will just give some result that might or
>> might not be meaningful. But there is no guarantee in almost any
>> language of some kind of specific meaningful result. Try it in FORTRAN
>> and see what you get there, or Cobol (or BASIC). :-)
>
> The issue, and the reason for the complex initial explanation,
> is the subtle interaction between the implicit type promotion
> rules, arithmetic, undefined behavior, and the freedom that UB
> gives to compiler writers, which is pretty unique to C. Hence
> why optimizing compilers often _appear_ to introduce bugs when
> in fact they're performing perfectly legal transformations, and
> turning off the optimizer can appear to "fix" the problem.

Yup. You were right. Sorry that I had to go and read the spec again.
Trusting my brain was obviously the wrong thing to do.

Johnny

Re: VMS Cobol - GnuCOBOL

<k6e8a5Fu2e4U5@mid.individual.net>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=27063&group=comp.os.vms#27063

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: bill.gun...@gmail.com (bill)
Newsgroups: comp.os.vms
Subject: Re: VMS Cobol - GnuCOBOL
Date: Fri, 3 Mar 2023 07:42:44 -0500
Lines: 85
Message-ID: <k6e8a5Fu2e4U5@mid.individual.net>
References: <tsbev9$1rela$2@dont-email.me> <k66d38Ftd0kU10@mid.individual.net>
<ttljkd$668$1@reader2.panix.com> <ttnk0m$lg5$2@news.misty.com>
<ttnov2$7l7$1@reader2.panix.com> <ttsne6$ro6$1@news.misty.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net FyO9ZumkBRLx3F6mx/1UnAT1nV9benBJy/a0V1cpTntFlk+QCX
Cancel-Lock: sha1:1K/ys4i/mwVTWZ/i84LLOsPu7Tw=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Content-Language: en-US
In-Reply-To: <ttsne6$ro6$1@news.misty.com>
 by: bill - Fri, 3 Mar 2023 12:42 UTC

On 3/3/2023 6:59 AM, Johnny Billquist wrote:
> Damn! I learned something new today...
>
> On 2023-03-01 15:54, Dan Cross wrote:
>> In article <ttnk0m$lg5$2@news.misty.com>,
>> Johnny Billquist  <bqt@softjar.se> wrote:
>>> On 2023-02-28 20:11, Dan Cross wrote:
>
> [...]
>
>>> You overcomplicated the whole explanation.
>>
>> Hmm.
>
> I was wrong. :-)
>
>>> Basically, if you multiply two numbers, and the result would be bigger
>>> than the types involved, the result is undefined.
>>
>> Well...no.  _unsigned_ integer overflow in C is well-defined (it
>> has modular wrapping semantics; C11 sec 6.2.5 para 9).
>> Similarly, overflow of signed atomics is well-defined (C11 sec
>> 7.17.7.5 para 3), so this is not always true.
>
> I had actually missed that unsigned integers do have a defined overflow
> behavior. Thanks.
>
>>> In this case, the type
>>> is unsigned short. If the multiplication cause anything that don't fit
>>> into an unsigned short, then the result is undefined.
>>>
>>> And it's fairly easy to find two unsigned short numbers that when
>>> multiplied will give a result that don't fit into an unsigned short.
>>
>> The range of unsigned short has little to do with it, and
>> truncation of the result is fine too (again, defined to use
>> modular wrapping for unsigned types; C11 sec 6.3.1.3).  The
>> problem is entirely due to the promotion to _signed_ int prior
>> to the multiplication.  The fix, incidentally, is easy:
>>
>> unsigned short
>> mul(unsigned short a, unsigned short b)
>> {
>>     unsigned int aa = a, bb = b;
>>     return aa * bb;
>> }
>>
>> This is well-defined, even if the range of `unsigned short` is
>> the same as `unsigned int`, which is permitted by the standard.
>
> Right. My second error. It is allowed to promote a unsigned short to a
> signed int.
> I do feel that I don't entirely agree with that rule, but it's
> definitely written as such.
>
> Changing from unsigned to signed feels just as a freedom too much.
>
>>> It's really not that different from any other language. Some languages
>>> will throw an exception, others will just give some result that might or
>>> might not be meaningful. But there is no guarantee in almost any
>>> language of some kind of specific meaningful result. Try it in FORTRAN
>>> and see what you get there, or Cobol (or BASIC). :-)
>>
>> The issue, and the reason for the complex initial explanation,
>> is the subtle interaction between the implicit type promotion
>> rules, arithmetic, undefined behavior, and the freedom that UB
>> gives to compiler writers, which is pretty unique to C.  Hence
>> why optimizing compilers often _appear_ to introduce bugs when
>> in fact they're performing perfectly legal transformations, and
>> turning off the optimizer can appear to "fix" the problem.
>
> Yup. You were right. Sorry that I had to go and read the spec again.
> Trusting my brain was obviously the wrong thing to do.
>

And it really doesn't matter whether the result is truncation,
conversion to signed int, wrap around, throwing an exception or
undefined. The answer is still going to be wrong and the calculation
worthless. So, what's the point? Fix the damn code.

Go ahead, blame the language again.

bill

Re: VMS Cobol - GnuCOBOL

<ttstlv$l5hp$1@dont-email.me>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=27065&group=comp.os.vms#27065

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: arn...@vajhoej.dk (Arne Vajhøj)
Newsgroups: comp.os.vms
Subject: Re: VMS Cobol - GnuCOBOL
Date: Fri, 3 Mar 2023 08:45:30 -0500
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <ttstlv$l5hp$1@dont-email.me>
References: <tsbev9$1rela$2@dont-email.me> <k66d38Ftd0kU10@mid.individual.net>
<ttljkd$668$1@reader2.panix.com> <ttnk0m$lg5$2@news.misty.com>
<ttnov2$7l7$1@reader2.panix.com> <ttsne6$ro6$1@news.misty.com>
<k6e8a5Fu2e4U5@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 3 Mar 2023 13:45:35 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="f6e2eddf4a16a3fa5d2818989ddb9c13";
logging-data="693817"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+K6Qn+ugccGdqeJDeENbb/V9UlCucrcdQ="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Cancel-Lock: sha1:qolJvx+xTzOd3BBI8XRE3cRfc+w=
Content-Language: en-US
In-Reply-To: <k6e8a5Fu2e4U5@mid.individual.net>
 by: Arne Vajhøj - Fri, 3 Mar 2023 13:45 UTC

On 3/3/2023 7:42 AM, bill wrote:
> On 3/3/2023 6:59 AM, Johnny Billquist wrote:
>> On 2023-03-01 15:54, Dan Cross wrote:
>>> In article <ttnk0m$lg5$2@news.misty.com>,
>>> Johnny Billquist  <bqt@softjar.se> wrote:
>>>> Basically, if you multiply two numbers, and the result would be bigger
>>>> than the types involved, the result is undefined.
>>>
>>> Well...no.  _unsigned_ integer overflow in C is well-defined (it
>>> has modular wrapping semantics; C11 sec 6.2.5 para 9).
>>> Similarly, overflow of signed atomics is well-defined (C11 sec
>>> 7.17.7.5 para 3), so this is not always true.
>>
>> I had actually missed that unsigned integers do have a defined
>> overflow behavior.

>> Yup. You were right. Sorry that I had to go and read the spec again.

> And it really doesn't matter whether the result is truncation,
> conversion to signed int, wrap around, throwing an exception or
> undefined.  The answer is still going to be wrong and the calculation
> worthless.  So, what's the point?  Fix the damn code.
>
> Go ahead, blame the language again.

I do.

:-)

The choice that provide the safest code is to throw
an exception at integer overflow.

For the cases where modulus 2^n math make sense, then
either the developer would need to move data to a bigger
data type and do an explicit modulus or the language
could support:

modulus_math_only_use_if_you_know_what_you_are_doing {
// code
}

Arne

Re: VMS Cobol - GnuCOBOL

<ttt0a6$jkh$1@reader2.panix.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=27066&group=comp.os.vms#27066

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
From: cro...@spitfire.i.gajendra.net (Dan Cross)
Newsgroups: comp.os.vms
Subject: Re: VMS Cobol - GnuCOBOL
Date: Fri, 3 Mar 2023 14:30:30 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <ttt0a6$jkh$1@reader2.panix.com>
References: <tsbev9$1rela$2@dont-email.me> <ttnov2$7l7$1@reader2.panix.com> <ttsne6$ro6$1@news.misty.com> <k6e8a5Fu2e4U5@mid.individual.net>
Injection-Date: Fri, 3 Mar 2023 14:30:30 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
logging-data="20113"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)
 by: Dan Cross - Fri, 3 Mar 2023 14:30 UTC

In article <k6e8a5Fu2e4U5@mid.individual.net>,
bill <bill.gunshannon@gmail.com> wrote:
>On 3/3/2023 6:59 AM, Johnny Billquist wrote:
>> Damn! I learned something new today...
>>
>> On 2023-03-01 15:54, Dan Cross wrote:
>>> In article <ttnk0m$lg5$2@news.misty.com>,
>>> Johnny Billquist  <bqt@softjar.se> wrote:
>>>> On 2023-02-28 20:11, Dan Cross wrote:
>>
>> [...]
>>
>>>> You overcomplicated the whole explanation.
>>>
>>> Hmm.
>>
>> I was wrong. :-)
>>
>>>> Basically, if you multiply two numbers, and the result would be bigger
>>>> than the types involved, the result is undefined.
>>>
>>> Well...no.  _unsigned_ integer overflow in C is well-defined (it
>>> has modular wrapping semantics; C11 sec 6.2.5 para 9).
>>> Similarly, overflow of signed atomics is well-defined (C11 sec
>>> 7.17.7.5 para 3), so this is not always true.
>>
>> I had actually missed that unsigned integers do have a defined overflow
>> behavior. Thanks.
>>
>>>> In this case, the type
>>>> is unsigned short. If the multiplication cause anything that don't fit
>>>> into an unsigned short, then the result is undefined.
>>>>
>>>> And it's fairly easy to find two unsigned short numbers that when
>>>> multiplied will give a result that don't fit into an unsigned short.
>>>
>>> The range of unsigned short has little to do with it, and
>>> truncation of the result is fine too (again, defined to use
>>> modular wrapping for unsigned types; C11 sec 6.3.1.3).  The
>>> problem is entirely due to the promotion to _signed_ int prior
>>> to the multiplication.  The fix, incidentally, is easy:
>>>
>>> unsigned short
>>> mul(unsigned short a, unsigned short b)
>>> {
>>>     unsigned int aa = a, bb = b;
>>>     return aa * bb;
>>> }
>>>
>>> This is well-defined, even if the range of `unsigned short` is
>>> the same as `unsigned int`, which is permitted by the standard.
>>
>> Right. My second error. It is allowed to promote a unsigned short to a
>> signed int.
>> I do feel that I don't entirely agree with that rule, but it's
>> definitely written as such.
>>
>> Changing from unsigned to signed feels just as a freedom too much.
>>
>>>> It's really not that different from any other language. Some languages
>>>> will throw an exception, others will just give some result that might or
>>>> might not be meaningful. But there is no guarantee in almost any
>>>> language of some kind of specific meaningful result. Try it in FORTRAN
>>>> and see what you get there, or Cobol (or BASIC). :-)
>>>
>>> The issue, and the reason for the complex initial explanation,
>>> is the subtle interaction between the implicit type promotion
>>> rules, arithmetic, undefined behavior, and the freedom that UB
>>> gives to compiler writers, which is pretty unique to C.  Hence
>>> why optimizing compilers often _appear_ to introduce bugs when
>>> in fact they're performing perfectly legal transformations, and
>>> turning off the optimizer can appear to "fix" the problem.
>>
>> Yup. You were right. Sorry that I had to go and read the spec again.
>> Trusting my brain was obviously the wrong thing to do.
>>
>
>And it really doesn't matter whether the result is truncation,
>conversion to signed int, wrap around, throwing an exception or
>undefined. The answer is still going to be wrong and the calculation
>worthless. So, what's the point? Fix the damn code.

Bill, do you understand that there are application domains where
people want well-defined modular arithmetic on unsigned types?
You seem intent on dismissing this as a valid use case, by
repeatedly that the results are "worthless." As I pointed out
to you earlier in this thread, wrapping semantics can be very
useful.

>Go ahead, blame the language again.

Ok. I blame the language for having confuing semantics, and I
blame compiler writer for exploiting that at the expense of
programmers.

- Dan C.

Re: VMS Cobol - GnuCOBOL

<ttt0bj$jkh$2@reader2.panix.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=27067&group=comp.os.vms#27067

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
From: cro...@spitfire.i.gajendra.net (Dan Cross)
Newsgroups: comp.os.vms
Subject: Re: VMS Cobol - GnuCOBOL
Date: Fri, 3 Mar 2023 14:31:15 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <ttt0bj$jkh$2@reader2.panix.com>
References: <tsbev9$1rela$2@dont-email.me> <ttnk0m$lg5$2@news.misty.com> <ttnov2$7l7$1@reader2.panix.com> <ttsne6$ro6$1@news.misty.com>
Injection-Date: Fri, 3 Mar 2023 14:31:15 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
logging-data="20113"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)
 by: Dan Cross - Fri, 3 Mar 2023 14:31 UTC

In article <ttsne6$ro6$1@news.misty.com>,
Johnny Billquist <bqt@softjar.se> wrote:
>[snip]
>I do feel that I don't entirely agree with that rule, but it's
>definitely written as such.
>
>Changing from unsigned to signed feels just as a freedom too much.

For the record, I agree with you.

>[snip]
>Yup. You were right. Sorry that I had to go and read the spec again.
>Trusting my brain was obviously the wrong thing to do.

No problem!

- Dan C.

Re: VMS Cobol - GnuCOBOL

<ttu5qn$p67s$1@dont-email.me>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=27070&group=comp.os.vms#27070

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: arn...@vajhoej.dk (Arne Vajhøj)
Newsgroups: comp.os.vms
Subject: Re: VMS Cobol - GnuCOBOL
Date: Fri, 3 Mar 2023 20:10:43 -0500
Organization: A noiseless patient Spider
Lines: 139
Message-ID: <ttu5qn$p67s$1@dont-email.me>
References: <tsbev9$1rela$2@dont-email.me> <k66d38Ftd0kU10@mid.individual.net>
<ttljkd$668$1@reader2.panix.com> <ttnk0m$lg5$2@news.misty.com>
<ttnov2$7l7$1@reader2.panix.com> <ttsne6$ro6$1@news.misty.com>
<k6e8a5Fu2e4U5@mid.individual.net> <ttstlv$l5hp$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 4 Mar 2023 01:10:47 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="5c03a932f3ff9f57c81d64807287a55c";
logging-data="825596"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18V/ZPNiIU05i43+33lXmmSxrGXBuQElJc="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Cancel-Lock: sha1:u9BMCtKjBPxLeY0oUSWBBgB7SIk=
In-Reply-To: <ttstlv$l5hp$1@dont-email.me>
Content-Language: en-US
 by: Arne Vajhøj - Sat, 4 Mar 2023 01:10 UTC

On 3/3/2023 8:45 AM, Arne Vajhøj wrote:
> On 3/3/2023 7:42 AM, bill wrote:
>> And it really doesn't matter whether the result is truncation,
>> conversion to signed int, wrap around, throwing an exception or
>> undefined.  The answer is still going to be wrong and the calculation
>> worthless.  So, what's the point?  Fix the damn code.
>>
>> Go ahead, blame the language again.
>
> I do.
>
> :-)
>
> The choice that provide the safest code is to throw
> an exception at integer overflow.
>
> For the cases where modulus 2^n math make sense, then
> either the developer would need to move data to a bigger
> data type and do an explicit modulus or the language
> could support:
>
> modulus_math_only_use_if_you_know_what_you_are_doing {
>     // code
> }

Compare:

C (on VMS as this is comp.os.vms !):

$ type ovf.c
#include <stdio.h>

int main(int argc, char *argv[])
{ unsigned int pop;
unsigned int gdppercap;
unsigned int gdp;
pop = 300000000U;
gdppercap = 50000U;
gdp = pop * gdppercap;
(void)printf("%u people @ %u dollars = %u dollars\n", pop,
gdppercap, gdp);
return 0;
} $ cc/warn=ena:all ovf
$ link ovf
$ run ovf
300000000 people @ 50000 dollars = 1974202368 dollars
$ type bit.c
#include <stdio.h>

int main(int argc, char *argv[])
{ unsigned int word;
word = 0xF0F0F0F0U;
(void)printf("%08X\n", word);
word = word * 2U;
(void)printf("%08X\n", word);
return 0;
} $ cc/warn=ena:all bit
$ link bit
$ run bit
F0F0F0F0
E1E1E1E0

C# (not available on VMS so ...):

C:\Work>type ovf.cs
using System;

public class Program
{ public static void Main(string[] args)
{
uint pop;
uint gdppercap;
uint gdp;
pop = 300000000U;
gdppercap = 50000U;
gdp = pop * gdppercap;
Console.WriteLine("{0} people @ {1} dollars = {2} dollars\n",
pop, gdppercap, gdp);
}
}

C:\Work>csc ovf.cs
Microsoft (R) Visual C# Compiler version 4.3.0-3.22470.13 (80a8ce8d)
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Work>ovf
300000000 people @ 50000 dollars = 1974202368 dollars

C:\Work>csc /checked+ ovf.cs
Microsoft (R) Visual C# Compiler version 4.3.0-3.22470.13 (80a8ce8d)
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Work>ovf
Unhandled Exception: System.OverflowException: Arithmetic operation
resulted in
an overflow.
at Program.Main(String[] args)

C:\Work>type bit.cs
using System;

public class Program
{ public static void Main(string[] args)
{
uint word;
word = 0xF0F0F0F0U;
Console.WriteLine("{0,8:X}", word);
word = unchecked(word * 2U);
Console.WriteLine("{0,8:X}", word);
}
}

C:\Work>csc bit.cs
Microsoft (R) Visual C# Compiler version 4.3.0-3.22470.13 (80a8ce8d)
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Work>bit
F0F0F0F0
E1E1E1E0

C:\Work>csc /checked+ bit.cs
Microsoft (R) Visual C# Compiler version 4.3.0-3.22470.13 (80a8ce8d)
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Work>bit
F0F0F0F0
E1E1E1E0

(note that /checked+ is not default)

Arne

Re: VMS Cobol - GnuCOBOL

<tu012i$11cqk$1@dont-email.me>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=27071&group=comp.os.vms#27071

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: arn...@vajhoej.dk (Arne Vajhøj)
Newsgroups: comp.os.vms
Subject: Re: VMS Cobol - GnuCOBOL
Date: Sat, 4 Mar 2023 13:01:44 -0500
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <tu012i$11cqk$1@dont-email.me>
References: <tsbev9$1rela$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 4 Mar 2023 18:01:54 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="5c03a932f3ff9f57c81d64807287a55c";
logging-data="1094484"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX196Y/BvX1tzuzXQEKS1qglEIoqSKYHc7nY="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Cancel-Lock: sha1:2kYFpL70thTm1K0mhJLN7RBFNrE=
Content-Language: en-US
In-Reply-To: <tsbev9$1rela$2@dont-email.me>
 by: Arne Vajhøj - Sat, 4 Mar 2023 18:01 UTC

On 2/12/2023 2:34 PM, Arne Vajhøj wrote:
> VMS Tech Demo 6 - converting files between VMS Cobol and GnuCOBOL:
>   https://www.vajhoej.dk/arne/articles/vmstd6.html

Examples added for when GnuCOBOL use VBISAM
instead of BDB for indexed files.

BDB is technically better than VBISAM, but the license
for VBISAM (LGPL) is more attractive for some than the
license for BDB (AGPL or Oracle commercial).

GnuCOBOL with VBISAM is easy for Windows as Arnold Trembley
provides builds for none, BDB and VBISAM.

GnuCOBOL with VBISAM for Linux requires an "old fashioned"
build:
* get the prerequisites ready
* get the source
* configure --with-vbisam
* make
and all the associated fun.

Arne

Re: VMS Cobol - GnuCOBOL

<tu4pi3$nhe$1@news.misty.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=27076&group=comp.os.vms#27076

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!.POSTED.80-218-16-84.dclient.hispeed.ch!not-for-mail
From: bqt...@softjar.se (Johnny Billquist)
Newsgroups: comp.os.vms
Subject: Re: VMS Cobol - GnuCOBOL
Date: Mon, 6 Mar 2023 14:24:19 +0100
Organization: MGT Consulting
Message-ID: <tu4pi3$nhe$1@news.misty.com>
References: <tsbev9$1rela$2@dont-email.me> <k66d38Ftd0kU10@mid.individual.net>
<ttljkd$668$1@reader2.panix.com> <ttnk0m$lg5$2@news.misty.com>
<ttnov2$7l7$1@reader2.panix.com> <ttsne6$ro6$1@news.misty.com>
<k6e8a5Fu2e4U5@mid.individual.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 6 Mar 2023 13:24:20 -0000 (UTC)
Injection-Info: news.misty.com; posting-host="80-218-16-84.dclient.hispeed.ch:80.218.16.84";
logging-data="24110"; mail-complaints-to="abuse@misty.com"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.8.0
Content-Language: en-US
In-Reply-To: <k6e8a5Fu2e4U5@mid.individual.net>
 by: Johnny Billquist - Mon, 6 Mar 2023 13:24 UTC

On 2023-03-03 13:42, bill wrote:
> On 3/3/2023 6:59 AM, Johnny Billquist wrote:
>> Damn! I learned something new today...
>>
>> On 2023-03-01 15:54, Dan Cross wrote:
>>> In article <ttnk0m$lg5$2@news.misty.com>,
>>> Johnny Billquist  <bqt@softjar.se> wrote:
>>>> On 2023-02-28 20:11, Dan Cross wrote:
>>
>> [...]
>>
>>>> You overcomplicated the whole explanation.
>>>
>>> Hmm.
>>
>> I was wrong. :-)
>>
>>>> Basically, if you multiply two numbers, and the result would be bigger
>>>> than the types involved, the result is undefined.
>>>
>>> Well...no.  _unsigned_ integer overflow in C is well-defined (it
>>> has modular wrapping semantics; C11 sec 6.2.5 para 9).
>>> Similarly, overflow of signed atomics is well-defined (C11 sec
>>> 7.17.7.5 para 3), so this is not always true.
>>
>> I had actually missed that unsigned integers do have a defined
>> overflow behavior. Thanks.
>>
>>>> In this case, the type
>>>> is unsigned short. If the multiplication cause anything that don't fit
>>>> into an unsigned short, then the result is undefined.
>>>>
>>>> And it's fairly easy to find two unsigned short numbers that when
>>>> multiplied will give a result that don't fit into an unsigned short.
>>>
>>> The range of unsigned short has little to do with it, and
>>> truncation of the result is fine too (again, defined to use
>>> modular wrapping for unsigned types; C11 sec 6.3.1.3).  The
>>> problem is entirely due to the promotion to _signed_ int prior
>>> to the multiplication.  The fix, incidentally, is easy:
>>>
>>> unsigned short
>>> mul(unsigned short a, unsigned short b)
>>> {
>>>     unsigned int aa = a, bb = b;
>>>     return aa * bb;
>>> }
>>>
>>> This is well-defined, even if the range of `unsigned short` is
>>> the same as `unsigned int`, which is permitted by the standard.
>>
>> Right. My second error. It is allowed to promote a unsigned short to a
>> signed int.
>> I do feel that I don't entirely agree with that rule, but it's
>> definitely written as such.
>>
>> Changing from unsigned to signed feels just as a freedom too much.
>>
>>>> It's really not that different from any other language. Some languages
>>>> will throw an exception, others will just give some result that
>>>> might or
>>>> might not be meaningful. But there is no guarantee in almost any
>>>> language of some kind of specific meaningful result. Try it in FORTRAN
>>>> and see what you get there, or Cobol (or BASIC). :-)
>>>
>>> The issue, and the reason for the complex initial explanation,
>>> is the subtle interaction between the implicit type promotion
>>> rules, arithmetic, undefined behavior, and the freedom that UB
>>> gives to compiler writers, which is pretty unique to C.  Hence
>>> why optimizing compilers often _appear_ to introduce bugs when
>>> in fact they're performing perfectly legal transformations, and
>>> turning off the optimizer can appear to "fix" the problem.
>>
>> Yup. You were right. Sorry that I had to go and read the spec again.
>> Trusting my brain was obviously the wrong thing to do.
>>
>
> And it really doesn't matter whether the result is truncation,
> conversion to signed int, wrap around, throwing an exception or
> undefined.  The answer is still going to be wrong and the calculation
> worthless.  So, what's the point?  Fix the damn code.
>
> Go ahead, blame the language again.

No. I don't fully agree. The fact that unsigned types are defined to
have the wrapping behavior means that you could definitely do this
intentionally and for rather good reasons.

But the type propagation rule here breaks that promise, which is what I
find *very* broken. I do consider it a error in the language
specification when this can happen.

Johnny

Re: VMS Cobol - GnuCOBOL

<tu4pp5$nhe$2@news.misty.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=27077&group=comp.os.vms#27077

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!.POSTED.80-218-16-84.dclient.hispeed.ch!not-for-mail
From: bqt...@softjar.se (Johnny Billquist)
Newsgroups: comp.os.vms
Subject: Re: VMS Cobol - GnuCOBOL
Date: Mon, 6 Mar 2023 14:28:04 +0100
Organization: MGT Consulting
Message-ID: <tu4pp5$nhe$2@news.misty.com>
References: <tsbev9$1rela$2@dont-email.me> <k66d38Ftd0kU10@mid.individual.net>
<ttljkd$668$1@reader2.panix.com> <ttnk0m$lg5$2@news.misty.com>
<ttnov2$7l7$1@reader2.panix.com> <ttsne6$ro6$1@news.misty.com>
<k6e8a5Fu2e4U5@mid.individual.net> <ttstlv$l5hp$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 6 Mar 2023 13:28:05 -0000 (UTC)
Injection-Info: news.misty.com; posting-host="80-218-16-84.dclient.hispeed.ch:80.218.16.84";
logging-data="24110"; mail-complaints-to="abuse@misty.com"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.8.0
Content-Language: en-US
In-Reply-To: <ttstlv$l5hp$1@dont-email.me>
 by: Johnny Billquist - Mon, 6 Mar 2023 13:28 UTC

On 2023-03-03 14:45, Arne Vajhøj wrote:
> On 3/3/2023 7:42 AM, bill wrote:
>> On 3/3/2023 6:59 AM, Johnny Billquist wrote:
>>> On 2023-03-01 15:54, Dan Cross wrote:
>>>> In article <ttnk0m$lg5$2@news.misty.com>,
>>>> Johnny Billquist  <bqt@softjar.se> wrote:
>>>>> Basically, if you multiply two numbers, and the result would be bigger
>>>>> than the types involved, the result is undefined.
>>>>
>>>> Well...no.  _unsigned_ integer overflow in C is well-defined (it
>>>> has modular wrapping semantics; C11 sec 6.2.5 para 9).
>>>> Similarly, overflow of signed atomics is well-defined (C11 sec
>>>> 7.17.7.5 para 3), so this is not always true.
>>>
>>> I had actually missed that unsigned integers do have a defined
>>> overflow behavior.
>
>>> Yup. You were right. Sorry that I had to go and read the spec again.
>
>> And it really doesn't matter whether the result is truncation,
>> conversion to signed int, wrap around, throwing an exception or
>> undefined.  The answer is still going to be wrong and the calculation
>> worthless.  So, what's the point?  Fix the damn code.
>>
>> Go ahead, blame the language again.
>
> I do.
>
> :-)
>
> The choice that provide the safest code is to throw
> an exception at integer overflow.

C don't have exceptions. And it can be argues if that is safe as well.

> For the cases where modulus 2^n math make sense, then
> either the developer would need to move data to a bigger
> data type and do an explicit modulus or the language
> could support:

The sad thing is that C is basically saying that this should be done
with 2^n modulus math. However, the rule saying that a unsigned short
can be propagated to a signed int is fucking you over. Technically, it's
ok since a signed int can fit all values that an unsigned short can.
However, a signed int is not defined to have a 2^n modulus behavior, so
in essence, behind your back, the compiler changed to a type with a
different behavior which invalidates something you expected/were
promised by the language.

Johnny

Pages:123456
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor