Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"We can't schedule an orgy, it might be construed as fighting" -- Stanley Sutton


devel / comp.lang.c / Re: bart again (UCX64)

SubjectAuthor
* bart again (UCX64)Paul Edwards
+* Re: bart again (UCX64)Bart
|+* Re: bart again (UCX64)Paul Edwards
||`* Re: bart again (UCX64)Bart
|| +- Re: bart again (UCX64)Paul Edwards
|| `- Re: bart again (UCX64)Dan Cross
|+* Re: bart again (UCX64)Bart
||`* Re: bart again (UCX64)Paul Edwards
|| `* Re: bart again (UCX64)Bart
||  `- Re: bart again (UCX64)Paul Edwards
|`- Re: bart again (UCX64)Chris M. Thomasson
+- Re: bart again (UCX64)Paul Edwards
+* Re: bart again (UCX64)Anton Shepelev
|`* Re: bart again (UCX64)Paul Edwards
| `* Re: bart again (UCX64)Bart
|  `* Re: bart again (UCX64)Paul Edwards
|   +* Re: bart again (UCX64)Paul Edwards
|   |`- Re: bart again (UCX64)Paul Edwards
|   `* Re: bart again (UCX64)Bart
|    +* Re: bart again (UCX64)Paul Edwards
|    |`* Re: bart again (UCX64)Bart
|    | `* Re: bart again (UCX64)Paul Edwards
|    |  `* Re: bart again (UCX64)Bart
|    |   `* Re: bart again (UCX64)Paul Edwards
|    |    +* Re: bart again (UCX64)Bart
|    |    |`- Re: bart again (UCX64)Paul Edwards
|    |    `* Re: bart again (UCX64)Bart
|    |     +* Re: bart again (UCX64)Paul Edwards
|    |     |+* Re: bart again (UCX64)Bart
|    |     ||`* Re: bart again (UCX64)Paul Edwards
|    |     || +* Re: bart again (UCX64)Bart
|    |     || |+- Re: bart again (UCX64)Paul Edwards
|    |     || |`* Re: bart again (UCX64)Keith Thompson
|    |     || | `* Re: bart again (UCX64)Scott Lurndal
|    |     || |  `- Re: bart again (UCX64)David Brown
|    |     || `- Re: bart again (UCX64)Paul Edwards
|    |     |`* Re: bart again (UCX64)Scott Lurndal
|    |     | `- Re: bart again (UCX64)Ben Bacarisse
|    |     `* Re: bart again (UCX64)David Brown
|    |      `* Re: bart again (UCX64)Bart
|    |       +- Re: bart again (UCX64)Bart
|    |       +* Re: bart again (UCX64)David Brown
|    |       |`* Re: bart again (UCX64)Bart
|    |       | +* Re: bart again (UCX64)Keith Thompson
|    |       | |+* Verbosity in command output (Was: bart again (UCX64))Kenny McCormack
|    |       | ||`* Re: Verbosity in command output (Was: bart again (UCX64))Kaz Kylheku
|    |       | || `* Re: Verbosity in command output (Was: bart again (UCX64))Malcolm McLean
|    |       | ||  `- Re: Verbosity in command output (Was: bart again (UCX64))Kaz Kylheku
|    |       | |`* Re: bart again (UCX64)Bart
|    |       | | `- Re: bart again (UCX64)Keith Thompson
|    |       | +- Re: bart again (UCX64)Scott Lurndal
|    |       | +* Re: bart again (UCX64)Scott Lurndal
|    |       | |`* Re: bart again (UCX64)Bart
|    |       | | +- Re: bart again (UCX64)Scott Lurndal
|    |       | | +* Re: bart again (UCX64)Keith Thompson
|    |       | | |`* Re: bart again (UCX64)Bart
|    |       | | | +* Re: bart again (UCX64)Paul Edwards
|    |       | | | |+* Re: bart again (UCX64)Chris M. Thomasson
|    |       | | | ||`* Re: bart again (UCX64)Paul Edwards
|    |       | | | || `- Re: bart again (UCX64)Kaz Kylheku
|    |       | | | |`- Re: bart again (UCX64)Bart
|    |       | | | +- Re: bart again (UCX64)Kaz Kylheku
|    |       | | | `- Re: bart again (UCX64)Keith Thompson
|    |       | | `* Re: bart again (UCX64)David Brown
|    |       | |  `* Re: bart again (UCX64)Bart
|    |       | |   +- Re: bart again (UCX64)David Brown
|    |       | |   +* Re: bart again (UCX64)Richard Harnden
|    |       | |   |`* Re: bart again (UCX64)Bart
|    |       | |   | +- Re: bart again (UCX64)David Brown
|    |       | |   | +* Re: bart again (UCX64)Richard Harnden
|    |       | |   | |+- Re: bart again (UCX64)David Brown
|    |       | |   | |`* Re: bart again (UCX64)Bart
|    |       | |   | | `- Re: bart again (UCX64)Kaz Kylheku
|    |       | |   | +* Re: bart again (UCX64)Ben Bacarisse
|    |       | |   | |`* Re: bart again (UCX64)Bart
|    |       | |   | | +* Re: bart again (UCX64)Ben Bacarisse
|    |       | |   | | |`* Re: bart again (UCX64)Bart
|    |       | |   | | | +* Re: bart again (UCX64)Kaz Kylheku
|    |       | |   | | | |`* Re: bart again (UCX64)Bart
|    |       | |   | | | | `* Re: bart again (UCX64)Kaz Kylheku
|    |       | |   | | | |  `* Re: bart again (UCX64)Bart
|    |       | |   | | | |   +* Re: bart again (UCX64)Kaz Kylheku
|    |       | |   | | | |   |`* Re: bart again (UCX64)Bart
|    |       | |   | | | |   | `* Re: bart again (UCX64)Ben Bacarisse
|    |       | |   | | | |   |  `* Re: bart again (UCX64)Bart
|    |       | |   | | | |   |   `* Re: bart again (UCX64)Ben Bacarisse
|    |       | |   | | | |   |    `* Re: bart again (UCX64)Bart
|    |       | |   | | | |   |     +* Re: bart again (UCX64)Malcolm McLean
|    |       | |   | | | |   |     |+* Re: bart again (UCX64)Bart
|    |       | |   | | | |   |     ||`* Re: bart again (UCX64)Malcolm McLean
|    |       | |   | | | |   |     || `* Re: bart again (UCX64)Ben Bacarisse
|    |       | |   | | | |   |     ||  `* Re: bart again (UCX64)Bart
|    |       | |   | | | |   |     ||   `- Re: bart again (UCX64)Ben Bacarisse
|    |       | |   | | | |   |     |`- Re: bart again (UCX64)David Brown
|    |       | |   | | | |   |     +- Re: bart again (UCX64)Ben Bacarisse
|    |       | |   | | | |   |     `* Re: bart again (UCX64)Kaz Kylheku
|    |       | |   | | | |   |      +* Re: bart again (UCX64)Ben Bacarisse
|    |       | |   | | | |   |      |`* Re: bart again (UCX64)Kaz Kylheku
|    |       | |   | | | |   |      | +* Re: bart again (UCX64)Ben Bacarisse
|    |       | |   | | | |   |      | |`* Re: bart again (UCX64)Bart
|    |       | |   | | | |   |      | | +- Re: bart again (UCX64)Kaz Kylheku
|    |       | |   | | | |   |      | | `- Re: bart again (UCX64)Ben Bacarisse
|    |       | |   | | | |   |      | `* Re: bart again (UCX64)Bart
|    |       | |   | | | |   |      `- Re: bart again (UCX64)Keith Thompson
|    |       | |   | | | |   `- Re: bart again (UCX64)David Brown
|    |       | |   | | | `* Re: bart again (UCX64)Ben Bacarisse
|    |       | |   | | `* Re: bart again (UCX64)Kaz Kylheku
|    |       | |   | `- Re: bart again (UCX64)Kaz Kylheku
|    |       | |   `* Re: bart again (UCX64)Kaz Kylheku
|    |       | `* Re: bart again (UCX64)David Brown
|    |       `* Re: bart again (UCX64)Kaz Kylheku
|    `* Re: bart again (UCX64)Paul Edwards
`* Re: bart again (UCX64)Michael S

Pages:12345678910111213141516
Re: bart again (UCX64)

<uctaf3$3v98j$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: bart again (UCX64)
Date: Fri, 1 Sep 2023 19:27:47 +0100
Organization: A noiseless patient Spider
Lines: 66
Message-ID: <uctaf3$3v98j$1@dont-email.me>
References: <b74c088d-09e6-4842-8b6c-1921d68154c7n@googlegroups.com>
<ucn66n$2n166$1@dont-email.me>
<d500e1f2-7486-4425-a7e2-4472cce70e44n@googlegroups.com>
<ucnl64$2p8as$1@dont-email.me>
<65d28a7d-ffd5-4b8b-b3f0-2500bb05f9b7n@googlegroups.com>
<ucoe3l$2t4o2$1@dont-email.me>
<557bf807-40c7-404b-9242-c26975faa42fn@googlegroups.com>
<ucprpd$38s6i$1@dont-email.me> <ucq1gd$39q14$1@dont-email.me>
<ucq86h$3auvq$1@dont-email.me> <ucqj27$3con1$1@dont-email.me>
<ucqpgp$3dnop$1@dont-email.me> <aa8IM.249421$f7Ub.27491@fx47.iad>
<ucr3kb$3f58o$1@dont-email.me> <ucs9pb$3nd9i$1@dont-email.me>
<ucsg9u$3ofr6$1@dont-email.me> <ucsk81$3p2kg$1@dont-email.me>
<ucsm1u$3pb1c$1@dont-email.me> <871qfiknil.fsf@bsb.me.uk>
<ucsu3s$3qfrk$1@dont-email.me> <87v8ctkbsj.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 1 Sep 2023 18:27:47 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="dde9efc24256f8d58e400f7792eddc71";
logging-data="4171027"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/EL8rG5OeG5ENQ5zc0HpJ9chaxVDoowuY="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:y3NZShRzDL//Z+3SSpUxwlyA4Z4=
In-Reply-To: <87v8ctkbsj.fsf@bsb.me.uk>
 by: Bart - Fri, 1 Sep 2023 18:27 UTC

On 01/09/2023 19:07, Ben Bacarisse wrote:
> Bart <bc@freeuk.com> writes:
>
>> On 01/09/2023 14:53, Ben Bacarisse wrote:
>>> Bart <bc@freeuk.com> writes:
>>>
>>>> On 01/09/2023 13:08, Richard Harnden wrote:
>>>>> On 01/09/2023 12:01, Bart wrote:
>>>
>>>>>> We are talking about compilers like gcc where you make up your own rules
>>>>>> as to show strictly you want your program treated:
>>>>>>
>>>>>>   gcc prog.c              zero warnings, writes .exe
>>>>>>   gcc @options prog.c     10000 warnings, but it still writes .exe
>>>>>>   gcc @options prog.c     10000 warning and 1 error, no .exe
>>>
>>> Which would you choose as the one and only behaviour?
>
> No answer? I'll look at the rest of your post, if you decide to address
> this point...

I'm not the compiler. It's supposed to tell me if my program passes.

There are apparently millions of possibilities, from zero errors to
1000s, for example if you apply -Werror.

Yes, it would be great if exam papers worked like that, you can choose
how strictly they should be marked!

But it's somewhat worrying here.

You want an answer, I'd go with the first, since then the three
compilers I use the most work the same way.

That's not completely satisfactory, since there are aspects of the C
language I think are too unsafe, but:

* Have to be passed because they are legal C

* Cannot reliably be detected by a compiler

* Are too extensively used in legacy code to be just outlawed.

In mine, I deal with the last by having a legacy option (called -old)
that needs to be invoked for existing programs. But unlike ones like
gcc, that is not the default; the option must be specified.

So my product works with two dialects, old and new.

But its behaviour, given one of those, is unequivocal:

bcc prog zero errors, writes .exe

or:

bcc prog exactly one error (as it stops compilation),
no .exe produced

Given that I have a short memory, and can only fix one error at a time,
that is reasonable.

Also time to restart compilation is not an issue; it's not as though it
is an overnight build using punched cards and you have to find as many
things wrong as possible during each attempt.

Re: bart again (UCX64)

<20230901112550.821@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: bart again (UCX64)
Date: Fri, 1 Sep 2023 18:32:02 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <20230901112550.821@kylheku.com>
References: <b74c088d-09e6-4842-8b6c-1921d68154c7n@googlegroups.com>
<ucn66n$2n166$1@dont-email.me>
<d500e1f2-7486-4425-a7e2-4472cce70e44n@googlegroups.com>
<ucnl64$2p8as$1@dont-email.me>
<65d28a7d-ffd5-4b8b-b3f0-2500bb05f9b7n@googlegroups.com>
<ucoe3l$2t4o2$1@dont-email.me>
<557bf807-40c7-404b-9242-c26975faa42fn@googlegroups.com>
<ucprpd$38s6i$1@dont-email.me> <ucq1gd$39q14$1@dont-email.me>
<ucq86h$3auvq$1@dont-email.me> <ucqj27$3con1$1@dont-email.me>
<ucqpgp$3dnop$1@dont-email.me> <aa8IM.249421$f7Ub.27491@fx47.iad>
<ucr3kb$3f58o$1@dont-email.me> <ucs9pb$3nd9i$1@dont-email.me>
<ucsg9u$3ofr6$1@dont-email.me> <ucsk81$3p2kg$1@dont-email.me>
<ucsm1u$3pb1c$1@dont-email.me> <871qfiknil.fsf@bsb.me.uk>
<ucsu3s$3qfrk$1@dont-email.me>
Injection-Date: Fri, 1 Sep 2023 18:32:02 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d7d6043c57cccad85a622dc3d680f17e";
logging-data="4172376"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+OogEAhEY6FfE/Yi8hdUEsIZbHd9aLUZc="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:cImz84x3v1k0o+cxRRwL87yzqhY=
 by: Kaz Kylheku - Fri, 1 Sep 2023 18:32 UTC

On 2023-09-01, Bart <bc@freeuk.com> wrote:
> On 01/09/2023 14:53, Ben Bacarisse wrote:
>> Is that true? #pragma GCC diagnostic "-Wno-xxxx" lines are not
>> overruled by command line warning options, but there may be a way to
>> force these to be ignored.
>
> Those don't always work. At least this doesn't:
>
> #pragma GCC diagnostic ignored "-Wbuiltin-declaration-mismatch"
>
> It works on Windows gcc but not WSL gcc.

"WSL gcc" is not the designation of a version of GCC.

Not all versions of GCC have the same -W options because, doh,
new ones get added over time.

Unfortunately, when you give a new -W option to an old GCC,
it has a fit about an unrecognized option and bails.

Projects that want to take advantage of new options, but still
work with olde GCC's, have a slight problem.

One approach is to detect what options work, in your ./configure script.

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

Re: bart again (UCX64)

<20230901114625.198@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: bart again (UCX64)
Date: Fri, 1 Sep 2023 18:49:23 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <20230901114625.198@kylheku.com>
References: <b74c088d-09e6-4842-8b6c-1921d68154c7n@googlegroups.com>
<ucn66n$2n166$1@dont-email.me>
<d500e1f2-7486-4425-a7e2-4472cce70e44n@googlegroups.com>
<ucnl64$2p8as$1@dont-email.me>
<65d28a7d-ffd5-4b8b-b3f0-2500bb05f9b7n@googlegroups.com>
<ucoe3l$2t4o2$1@dont-email.me>
<557bf807-40c7-404b-9242-c26975faa42fn@googlegroups.com>
<ucprpd$38s6i$1@dont-email.me> <ucq1gd$39q14$1@dont-email.me>
<ucq86h$3auvq$1@dont-email.me> <ucqj27$3con1$1@dont-email.me>
<ucqpgp$3dnop$1@dont-email.me> <aa8IM.249421$f7Ub.27491@fx47.iad>
<ucr3kb$3f58o$1@dont-email.me> <ucs9pb$3nd9i$1@dont-email.me>
<ucsg9u$3ofr6$1@dont-email.me> <20230901104426.371@kylheku.com>
<uct9hv$3v1lb$2@dont-email.me>
Injection-Date: Fri, 1 Sep 2023 18:49:23 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d7d6043c57cccad85a622dc3d680f17e";
logging-data="4176411"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18gx33Vx0h1sD6ICG4d4n9LF3JYMX2I714="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:tVzqpLrJhEcLm89owx6Ak2ZbQNM=
 by: Kaz Kylheku - Fri, 1 Sep 2023 18:49 UTC

On 2023-09-01, Bart <bc@freeuk.com> wrote:
> Is my program correct? Apparently gcc can't tell me; *I* have to tell
> *it*. You pretty much say that above.

GCC can't tell you whether a program is correct, because it can't read
your requirement specification, high level design or detailed design.
It doesn't run your program, let alone execute test cases on it.

> OK, *I* say then that if 'gcc prog.c' works with no notes, warnings or
> messages, then my program is fine.

Even if ./a.out segfaults? Yes, if the requirement specification
for the program is "write me small program that segfaults on Unix".
It would then be incorrect if it terminated normally.

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

Re: bart again (UCX64)

<20230901114952.369@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: bart again (UCX64)
Date: Fri, 1 Sep 2023 18:53:11 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <20230901114952.369@kylheku.com>
References: <b74c088d-09e6-4842-8b6c-1921d68154c7n@googlegroups.com>
<ucn66n$2n166$1@dont-email.me>
<d500e1f2-7486-4425-a7e2-4472cce70e44n@googlegroups.com>
<ucnl64$2p8as$1@dont-email.me>
<65d28a7d-ffd5-4b8b-b3f0-2500bb05f9b7n@googlegroups.com>
<ucoe3l$2t4o2$1@dont-email.me>
<557bf807-40c7-404b-9242-c26975faa42fn@googlegroups.com>
<ucprpd$38s6i$1@dont-email.me> <ucq1gd$39q14$1@dont-email.me>
<ucq86h$3auvq$1@dont-email.me> <ucqj27$3con1$1@dont-email.me>
<ucqpgp$3dnop$1@dont-email.me> <aa8IM.249421$f7Ub.27491@fx47.iad>
<ucr3kb$3f58o$1@dont-email.me> <ucs9pb$3nd9i$1@dont-email.me>
<ucsg9u$3ofr6$1@dont-email.me> <ucsk81$3p2kg$1@dont-email.me>
<ucsm1u$3pb1c$1@dont-email.me> <ucsp6b$3pog4$1@dont-email.me>
<uct8ss$3v1lb$1@dont-email.me>
Injection-Date: Fri, 1 Sep 2023 18:53:11 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d7d6043c57cccad85a622dc3d680f17e";
logging-data="4176411"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18G4yQXyDeA8M+yK/ucukS33bar4j0JAhk="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:KaK21Rz5UK175TjMKR5ChXN2D3I=
 by: Kaz Kylheku - Fri, 1 Sep 2023 18:53 UTC

On 2023-09-01, Bart <bc@freeuk.com> wrote:
> If I compile my generated C with any of:
>
> bcc prog
> tcc prog.c
> gcc prog.c -oprog
>
> it works perfectly.
>
> Unless there's actually something wrong with prog.c. In that case:
>
> * Why doesn't gcc show any errors?

Because, in general, determining that "something is wrong" with a
program is equivalent in difficulty to the Halting Problem, **and**
being able to tell that something is wrong requires understanding the
requirements specification for the program.

> * Why not even warnings?

You've not specified -W, and the program doesn't violate any
syntax rulews or constraint rules of GNU C (the default dialect).

> * Why is it generating an executable?

That compiler have you written that emits diagnostics and fails to
generate an executable whenever "something is wrong" with the program,
and how did you do it?

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

Re: bart again (UCX64)

<20230901115322.184@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: bart again (UCX64)
Date: Fri, 1 Sep 2023 18:55:58 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <20230901115322.184@kylheku.com>
References: <b74c088d-09e6-4842-8b6c-1921d68154c7n@googlegroups.com>
<ucn66n$2n166$1@dont-email.me>
<d500e1f2-7486-4425-a7e2-4472cce70e44n@googlegroups.com>
<ucnl64$2p8as$1@dont-email.me>
<65d28a7d-ffd5-4b8b-b3f0-2500bb05f9b7n@googlegroups.com>
<ucoe3l$2t4o2$1@dont-email.me>
<557bf807-40c7-404b-9242-c26975faa42fn@googlegroups.com>
<ucprpd$38s6i$1@dont-email.me> <ucq1gd$39q14$1@dont-email.me>
<ucq86h$3auvq$1@dont-email.me> <ucqj27$3con1$1@dont-email.me>
<ucqpgp$3dnop$1@dont-email.me> <aa8IM.249421$f7Ub.27491@fx47.iad>
<ucr3kb$3f58o$1@dont-email.me> <ucs9pb$3nd9i$1@dont-email.me>
<ucsg9u$3ofr6$1@dont-email.me> <ucsk81$3p2kg$1@dont-email.me>
<ucsm1u$3pb1c$1@dont-email.me> <871qfiknil.fsf@bsb.me.uk>
<ucsu3s$3qfrk$1@dont-email.me> <87v8ctkbsj.fsf@bsb.me.uk>
<uctaf3$3v98j$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 1 Sep 2023 18:55:58 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d7d6043c57cccad85a622dc3d680f17e";
logging-data="4176411"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+5T3yda4iJ7Z038Ayj2hHOGfdAypyw/ho="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:FUhFGyZEn8JMOPUloqUIpIMuZ2c=
 by: Kaz Kylheku - Fri, 1 Sep 2023 18:55 UTC

On 2023-09-01, Bart <bc@freeuk.com> wrote:
> On 01/09/2023 19:07, Ben Bacarisse wrote:
>> Bart <bc@freeuk.com> writes:
>>
>>> On 01/09/2023 14:53, Ben Bacarisse wrote:
>>>> Bart <bc@freeuk.com> writes:
>>>>
>>>>> On 01/09/2023 13:08, Richard Harnden wrote:
>>>>>> On 01/09/2023 12:01, Bart wrote:
>>>>
>>>>>>> We are talking about compilers like gcc where you make up your own rules
>>>>>>> as to show strictly you want your program treated:
>>>>>>>
>>>>>>>   gcc prog.c              zero warnings, writes .exe
>>>>>>>   gcc @options prog.c     10000 warnings, but it still writes .exe
>>>>>>>   gcc @options prog.c     10000 warning and 1 error, no .exe
>>>>
>>>> Which would you choose as the one and only behaviour?
>>
>> No answer? I'll look at the rest of your post, if you decide to address
>> this point...
>
> I'm not the compiler. It's supposed to tell me if my program passes.

Passes what? The regression test suite?

Is that what your own compilers do; build the program and run a
test suite?

Do they propose and generate the test suite, or does the hapless
programmer actually have to provide one?

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

Re: bart again (UCX64)

<DwqIM.79176$m8Ke.35724@fx08.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx08.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: bart again (UCX64)
Newsgroups: comp.lang.c
References: <b74c088d-09e6-4842-8b6c-1921d68154c7n@googlegroups.com> <ucprpd$38s6i$1@dont-email.me> <ucq1gd$39q14$1@dont-email.me> <ucq86h$3auvq$1@dont-email.me> <ucqj27$3con1$1@dont-email.me> <ucqpgp$3dnop$1@dont-email.me> <aa8IM.249421$f7Ub.27491@fx47.iad> <ucr3kb$3f58o$1@dont-email.me> <ucs9pb$3nd9i$1@dont-email.me> <ucsg9u$3ofr6$1@dont-email.me> <ucsk81$3p2kg$1@dont-email.me> <ucsm1u$3pb1c$1@dont-email.me> <871qfiknil.fsf@bsb.me.uk> <ucsu3s$3qfrk$1@dont-email.me> <20230901112550.821@kylheku.com>
Lines: 33
Message-ID: <DwqIM.79176$m8Ke.35724@fx08.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Fri, 01 Sep 2023 18:59:47 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Fri, 01 Sep 2023 18:59:47 GMT
X-Received-Bytes: 2319
 by: Scott Lurndal - Fri, 1 Sep 2023 18:59 UTC

Kaz Kylheku <864-117-4973@kylheku.com> writes:
>On 2023-09-01, Bart <bc@freeuk.com> wrote:
>> On 01/09/2023 14:53, Ben Bacarisse wrote:
>>> Is that true? #pragma GCC diagnostic "-Wno-xxxx" lines are not
>>> overruled by command line warning options, but there may be a way to
>>> force these to be ignored.
>>
>> Those don't always work. At least this doesn't:
>>
>> #pragma GCC diagnostic ignored "-Wbuiltin-declaration-mismatch"
>>
>> It works on Windows gcc but not WSL gcc.
>
>"WSL gcc" is not the designation of a version of GCC.
>
>Not all versions of GCC have the same -W options because, doh,
>new ones get added over time.
>
>Unfortunately, when you give a new -W option to an old GCC,
>it has a fit about an unrecognized option and bails.
>
>Projects that want to take advantage of new options, but still
>work with olde GCC's, have a slight problem.
>
>One approach is to detect what options work, in your ./configure script.

Or in the Makefile if you don't use autoconf.

GCC_HAS_GENERIC_TUNING := $(shell expr `$(CXX) -dumpversion | cut -f2 -d. ` \>= 2)
GCC_HAS_MCRC32 := $(shell expr `$(CXX) -E -mcrc32 /dev/null 2>/dev/null; echo $$?` == 0)

IS_GCC_MAJOR_VER_4 := $(shell if [ `$(CXX) -dumpversion | cut -f1 -d. ` -eq 4 ]; then echo 1; else echo 0; fi )

Re: bart again (UCX64)

<ucthg8$gvk$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: bart again (UCX64)
Date: Fri, 1 Sep 2023 21:27:52 +0100
Organization: A noiseless patient Spider
Lines: 62
Message-ID: <ucthg8$gvk$1@dont-email.me>
References: <b74c088d-09e6-4842-8b6c-1921d68154c7n@googlegroups.com>
<ucn66n$2n166$1@dont-email.me>
<d500e1f2-7486-4425-a7e2-4472cce70e44n@googlegroups.com>
<ucnl64$2p8as$1@dont-email.me>
<65d28a7d-ffd5-4b8b-b3f0-2500bb05f9b7n@googlegroups.com>
<ucoe3l$2t4o2$1@dont-email.me>
<557bf807-40c7-404b-9242-c26975faa42fn@googlegroups.com>
<ucprpd$38s6i$1@dont-email.me> <ucq1gd$39q14$1@dont-email.me>
<ucq86h$3auvq$1@dont-email.me> <ucqj27$3con1$1@dont-email.me>
<ucqpgp$3dnop$1@dont-email.me> <aa8IM.249421$f7Ub.27491@fx47.iad>
<ucr3kb$3f58o$1@dont-email.me> <ucs9pb$3nd9i$1@dont-email.me>
<ucsg9u$3ofr6$1@dont-email.me> <ucsk81$3p2kg$1@dont-email.me>
<ucsm1u$3pb1c$1@dont-email.me> <871qfiknil.fsf@bsb.me.uk>
<ucsu3s$3qfrk$1@dont-email.me> <87v8ctkbsj.fsf@bsb.me.uk>
<uctaf3$3v98j$1@dont-email.me> <20230901115322.184@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 1 Sep 2023 20:27:52 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="dde9efc24256f8d58e400f7792eddc71";
logging-data="17396"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+TSoW1FGfIc7X7qTVTjuhh7fUCXU7Dq+M="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:dW8Ve5NutMQTQJa++Lv9LUfpX6I=
In-Reply-To: <20230901115322.184@kylheku.com>
 by: Bart - Fri, 1 Sep 2023 20:27 UTC

On 01/09/2023 19:55, Kaz Kylheku wrote:
> On 2023-09-01, Bart <bc@freeuk.com> wrote:
>> On 01/09/2023 19:07, Ben Bacarisse wrote:
>>> Bart <bc@freeuk.com> writes:
>>>
>>>> On 01/09/2023 14:53, Ben Bacarisse wrote:
>>>>> Bart <bc@freeuk.com> writes:
>>>>>
>>>>>> On 01/09/2023 13:08, Richard Harnden wrote:
>>>>>>> On 01/09/2023 12:01, Bart wrote:
>>>>>
>>>>>>>> We are talking about compilers like gcc where you make up your own rules
>>>>>>>> as to show strictly you want your program treated:
>>>>>>>>
>>>>>>>>   gcc prog.c              zero warnings, writes .exe
>>>>>>>>   gcc @options prog.c     10000 warnings, but it still writes .exe
>>>>>>>>   gcc @options prog.c     10000 warning and 1 error, no .exe
>>>>>
>>>>> Which would you choose as the one and only behaviour?
>>>
>>> No answer? I'll look at the rest of your post, if you decide to address
>>> this point...
>>
>> I'm not the compiler. It's supposed to tell me if my program passes.
>
> Passes what? The regression test suite?
>
> Is that what your own compilers do; build the program and run a
> test suite?

So, what the hell does gcc actually do? gcc or any of its ilk since all
seem to want to emulate it.

I'm genuinely interested.

It seems incredibly laid-back about the whole business. Sometimes a
program is OK, sometimes it isn't, sometimes it fails, depending on how
how much of a bribe - sorry, a set of options - that you give it.

MY compilers check that an input sourcefile for language L has a valid
syntax, can fully resolve name references, obeys the type rules of the
language, and does various other bits and pieces.

If anything fails, it stops. If that's all OK according to the language
rules, it will produce an executable.

It doesn't do any speculative analysis. It can't tell whether logic or
design bugs exist or not. It doesn't get involved in what you do with
the executable, or what tests you might choose to perform.

It just does what is expected of a COMPILER - a tool to turn source code
into runnable binary code as instructed by program statements within
that source code.

So how does gcc manage to do pretty much what it likes, including either
compiling a program with no errors or warnings, or compiling the SAME
PROGRAM with fatal errors?

Re: bart again (UCX64)

<ucthrb$gvk$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: bart again (UCX64)
Date: Fri, 1 Sep 2023 21:33:49 +0100
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <ucthrb$gvk$2@dont-email.me>
References: <b74c088d-09e6-4842-8b6c-1921d68154c7n@googlegroups.com>
<ucn66n$2n166$1@dont-email.me>
<d500e1f2-7486-4425-a7e2-4472cce70e44n@googlegroups.com>
<ucnl64$2p8as$1@dont-email.me>
<65d28a7d-ffd5-4b8b-b3f0-2500bb05f9b7n@googlegroups.com>
<ucoe3l$2t4o2$1@dont-email.me>
<557bf807-40c7-404b-9242-c26975faa42fn@googlegroups.com>
<ucprpd$38s6i$1@dont-email.me> <ucq1gd$39q14$1@dont-email.me>
<ucq86h$3auvq$1@dont-email.me> <ucqj27$3con1$1@dont-email.me>
<ucqpgp$3dnop$1@dont-email.me> <aa8IM.249421$f7Ub.27491@fx47.iad>
<ucr3kb$3f58o$1@dont-email.me> <ucs9pb$3nd9i$1@dont-email.me>
<ucsg9u$3ofr6$1@dont-email.me> <20230901104426.371@kylheku.com>
<uct9hv$3v1lb$2@dont-email.me> <20230901114625.198@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 1 Sep 2023 20:33:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="dde9efc24256f8d58e400f7792eddc71";
logging-data="17396"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18glvx8B+C2Az4+AEXyg0F1+zHNuXUKq+0="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:euQOH4pblYt8Lzf1la0UEs7VmhE=
In-Reply-To: <20230901114625.198@kylheku.com>
 by: Bart - Fri, 1 Sep 2023 20:33 UTC

On 01/09/2023 19:49, Kaz Kylheku wrote:
> On 2023-09-01, Bart <bc@freeuk.com> wrote:
>> Is my program correct? Apparently gcc can't tell me; *I* have to tell
>> *it*. You pretty much say that above.
>
> GCC can't tell you whether a program is correct, because it can't read
> your requirement specification, high level design or detailed design.
> It doesn't run your program, let alone execute test cases on it.
>
>> OK, *I* say then that if 'gcc prog.c' works with no notes, warnings or
>> messages, then my program is fine.
>
> Even if ./a.out segfaults? Yes, if the requirement specification
> for the program is "write me small program that segfaults on Unix".
> It would then be incorrect if it terminated normally.
>

Ok, since you seem determined to misunderstand.

Is my program a valid C program? The answer seems to depend on a lot
more than just the source code submitted.

Re: bart again (UCX64)

<20230901133548.87@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: bart again (UCX64)
Date: Fri, 1 Sep 2023 20:46:50 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <20230901133548.87@kylheku.com>
References: <b74c088d-09e6-4842-8b6c-1921d68154c7n@googlegroups.com>
<ucn66n$2n166$1@dont-email.me>
<d500e1f2-7486-4425-a7e2-4472cce70e44n@googlegroups.com>
<ucnl64$2p8as$1@dont-email.me>
<65d28a7d-ffd5-4b8b-b3f0-2500bb05f9b7n@googlegroups.com>
<ucoe3l$2t4o2$1@dont-email.me>
<557bf807-40c7-404b-9242-c26975faa42fn@googlegroups.com>
<ucprpd$38s6i$1@dont-email.me> <ucq1gd$39q14$1@dont-email.me>
<ucq86h$3auvq$1@dont-email.me> <ucqj27$3con1$1@dont-email.me>
<ucqpgp$3dnop$1@dont-email.me> <aa8IM.249421$f7Ub.27491@fx47.iad>
<ucr3kb$3f58o$1@dont-email.me> <ucs9pb$3nd9i$1@dont-email.me>
<ucsg9u$3ofr6$1@dont-email.me> <ucsk81$3p2kg$1@dont-email.me>
<ucsm1u$3pb1c$1@dont-email.me> <871qfiknil.fsf@bsb.me.uk>
<ucsu3s$3qfrk$1@dont-email.me> <87v8ctkbsj.fsf@bsb.me.uk>
<uctaf3$3v98j$1@dont-email.me> <20230901115322.184@kylheku.com>
<ucthg8$gvk$1@dont-email.me>
Injection-Date: Fri, 1 Sep 2023 20:46:50 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d7d6043c57cccad85a622dc3d680f17e";
logging-data="22947"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/lXktvIWd9PsVD/b7nh1cIw31J6qC87fE="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:BZjIZbYFIPhDumU2gK83F+q46WU=
 by: Kaz Kylheku - Fri, 1 Sep 2023 20:46 UTC

On 2023-09-01, Bart <bc@freeuk.com> wrote:
> MY compilers check that an input sourcefile for language L has a valid
> syntax,

Which valid syntax? As of the last night's commit which added new
syntax?

What if I have code that uses last year's syntax, and for the
time being want to keep it that way (not have newer syntax
creeping in accidentally?)

Oh shit! Look, someone likes your language and has written their
own implementation. It has a few differences and extensions.
Users are starting to use them and complaining they don't work
in the original.

Do you support those, unconditionally?

> can fully resolve name references, obeys the type rules of the
> language, and does various other bits and pieces.

Do your compilers target PPC? I have a project that runs on big endian
PPC64. Also ported it to Loongarch: this new ISA from China.

SPARC? MIPS? RISCV?

Oh wait yes; thanks to GCC ...

> So how does gcc manage to do pretty much what it likes, including either
> compiling a program with no errors or warnings, or compiling the SAME
> PROGRAM with fatal errors?

By supporting forty years of C revisions, plus its dialect, plus having
flexible code generation and diagnosis options, that the users want and
depend on.

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

Re: bart again (UCX64)

<20230901135123.702@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: bart again (UCX64)
Date: Fri, 1 Sep 2023 21:09:16 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 54
Message-ID: <20230901135123.702@kylheku.com>
References: <b74c088d-09e6-4842-8b6c-1921d68154c7n@googlegroups.com>
<ucn66n$2n166$1@dont-email.me>
<d500e1f2-7486-4425-a7e2-4472cce70e44n@googlegroups.com>
<ucnl64$2p8as$1@dont-email.me>
<65d28a7d-ffd5-4b8b-b3f0-2500bb05f9b7n@googlegroups.com>
<ucoe3l$2t4o2$1@dont-email.me>
<557bf807-40c7-404b-9242-c26975faa42fn@googlegroups.com>
<ucprpd$38s6i$1@dont-email.me> <ucq1gd$39q14$1@dont-email.me>
<ucq86h$3auvq$1@dont-email.me> <ucqj27$3con1$1@dont-email.me>
<ucqpgp$3dnop$1@dont-email.me> <aa8IM.249421$f7Ub.27491@fx47.iad>
<ucr3kb$3f58o$1@dont-email.me> <ucs9pb$3nd9i$1@dont-email.me>
<ucsg9u$3ofr6$1@dont-email.me> <20230901104426.371@kylheku.com>
<uct9hv$3v1lb$2@dont-email.me> <20230901114625.198@kylheku.com>
<ucthrb$gvk$2@dont-email.me>
Injection-Date: Fri, 1 Sep 2023 21:09:16 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d7d6043c57cccad85a622dc3d680f17e";
logging-data="30477"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19S6+iAPQ6JbbDGumwOHoqwlUnv6UGK/e0="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:62pJvbBaTVvbclcDCN1gI16FxC0=
 by: Kaz Kylheku - Fri, 1 Sep 2023 21:09 UTC

On 2023-09-01, Bart <bc@freeuk.com> wrote:
> On 01/09/2023 19:49, Kaz Kylheku wrote:
>> On 2023-09-01, Bart <bc@freeuk.com> wrote:
>>> Is my program correct? Apparently gcc can't tell me; *I* have to tell
>>> *it*. You pretty much say that above.
>>
>> GCC can't tell you whether a program is correct, because it can't read
>> your requirement specification, high level design or detailed design.
>> It doesn't run your program, let alone execute test cases on it.
>>
>>> OK, *I* say then that if 'gcc prog.c' works with no notes, warnings or
>>> messages, then my program is fine.
>>
>> Even if ./a.out segfaults? Yes, if the requirement specification
>> for the program is "write me small program that segfaults on Unix".
>> It would then be incorrect if it terminated normally.
>>
>
> Ok, since you seem determined to misunderstand.

It's you who don't understand what "correct" means.

When you start talking about correctness, the program's specification
is involved.

In fact that is all that is involved. A null pointer dereference
or division by zero become correct if the specification says so.

> Is my program a valid C program? The answer seems to depend on a lot
> more than just the source code submitted.

C is a family of languages with many dialects. An almost fifty-year-old
family. C++ is a C dialect. Objective C is a C dialect.

What does your question mean?

Does your question mean "is this program a valid program in absolutely
any C dialect that has ever existed, such that all its externally
visible behaviors are the same?"

That's not easy to answer, or practically useful; maybe you
mean something else?

gcc is a program that processes code in the C family and other families.
It has dialect options, as well as customization that allow users
create custom dialects, within certain obvious limits.

A configuration of gcc processes one dialect, so it can tell you whether
the program is acceptable under that dialect.

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

Re: bart again (UCX64)

<uctl33$13ie$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: bart again (UCX64)
Date: Fri, 1 Sep 2023 22:29:07 +0100
Organization: A noiseless patient Spider
Lines: 106
Message-ID: <uctl33$13ie$1@dont-email.me>
References: <b74c088d-09e6-4842-8b6c-1921d68154c7n@googlegroups.com>
<ucn66n$2n166$1@dont-email.me>
<d500e1f2-7486-4425-a7e2-4472cce70e44n@googlegroups.com>
<ucnl64$2p8as$1@dont-email.me>
<65d28a7d-ffd5-4b8b-b3f0-2500bb05f9b7n@googlegroups.com>
<ucoe3l$2t4o2$1@dont-email.me>
<557bf807-40c7-404b-9242-c26975faa42fn@googlegroups.com>
<ucprpd$38s6i$1@dont-email.me> <ucq1gd$39q14$1@dont-email.me>
<ucq86h$3auvq$1@dont-email.me> <ucqj27$3con1$1@dont-email.me>
<ucqpgp$3dnop$1@dont-email.me> <aa8IM.249421$f7Ub.27491@fx47.iad>
<ucr3kb$3f58o$1@dont-email.me> <ucs9pb$3nd9i$1@dont-email.me>
<ucsg9u$3ofr6$1@dont-email.me> <ucsk81$3p2kg$1@dont-email.me>
<ucsm1u$3pb1c$1@dont-email.me> <871qfiknil.fsf@bsb.me.uk>
<ucsu3s$3qfrk$1@dont-email.me> <87v8ctkbsj.fsf@bsb.me.uk>
<uctaf3$3v98j$1@dont-email.me> <20230901115322.184@kylheku.com>
<ucthg8$gvk$1@dont-email.me> <20230901133548.87@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 1 Sep 2023 21:29:07 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="dde9efc24256f8d58e400f7792eddc71";
logging-data="36430"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19GVBElu75BP9egMId7+Au9QuDtVMrQdsg="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:CPGX4PEyHRwVEFxNXDWC+kqTZoQ=
In-Reply-To: <20230901133548.87@kylheku.com>
 by: Bart - Fri, 1 Sep 2023 21:29 UTC

On 01/09/2023 21:46, Kaz Kylheku wrote:
> On 2023-09-01, Bart <bc@freeuk.com> wrote:
>> MY compilers check that an input sourcefile for language L has a valid
>> syntax,
>
> Which valid syntax? As of the last night's commit which added new
> syntax?
>
> What if I have code that uses last year's syntax, and for the
> time being want to keep it that way (not have newer syntax
> creeping in accidentally?)
>
> Oh shit! Look, someone likes your language and has written their
> own implementation. It has a few differences and extensions.
> Users are starting to use them and complaining they don't work
> in the original.
>
> Do you support those, unconditionally?
>
>> can fully resolve name references, obeys the type rules of the
>> language, and does various other bits and pieces.
>
> Do your compilers target PPC? I have a project that runs on big endian
> PPC64. Also ported it to Loongarch: this new ISA from China.
>
> SPARC? MIPS? RISCV?
>
> Oh wait yes; thanks to GCC ...
>
>> So how does gcc manage to do pretty much what it likes, including either
>> compiling a program with no errors or warnings, or compiling the SAME
>> PROGRAM with fatal errors?
>
> By supporting forty years of C revisions, plus its dialect, plus having
> flexible code generation and diagnosis options, that the users want and
> depend on.
>

So you freely admit that C is a mess, and so are its compilers.

And yet, it is possible to create a compiler that gives the common-sense
results that one would expect. Except I'm not seeing it.

What do you expect the results of compiling this program with -c to be:

int fred(void){}

Here are the results I get:

Warnings Errors

gcc - -
tcc - -
clang 1 -
msvc 1 -
gcc -Wall 1 -
lccwin32 1 -
bcc - 1

The problem with that function, in case you haven't spotted it, is that
it does not return an 'int' value.

Yet, not one of those compilers other than bcc stops you creating an
executable containing a call to that function.

That can be serious, especially if the return type was a pointer.

This is just incredible. You can spout all the nonsense you like about
the long history of C, but there is no excuse for a compiler in 2023 to
pass code like that with default behaviour.

You have to give gcc -Wall to even get it to warn.

Yet, everyone here will either defend it to the death, or just brush it
off and say, Of couse, you have to provide the right options to get the
compiler to do its job properly.

(BTW, which option do you need to force a hard error on that program,
which doesn't also fail on unused lables?)

I would say, WHY doesn't it do its job anyway? WHY doesn't it operate in
a safer mode by default?

I can get my bcc to pass that program, but I have to specify -old, and
that is only so that existing can be compiled.

But why do so many existing programs have such code? Could it possibly
be because compilers have always allowed it? So the practice is
perpetuated instead of curtailed.

There is something very, very wrong with the culture of both C, and its
retinue of compilers.

Yes, I want a simple universal language that exists on every platform. I
just wish it was something better than this.

And BTW, WTF does it have to do with being to run on PPC? Does that
machine magically conjure the expected return value out of thin air. Or
are just trying to belittle my own efforts?

No doubt you, DB, KT, and everyone else will insist it is still my
fault. How about admitting that things are not as they should be?

Re: bart again (UCX64)

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

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: bart again (UCX64)
Date: Fri, 01 Sep 2023 14:31:58 -0700
Organization: None to speak of
Lines: 54
Message-ID: <87msy57f75.fsf@nosuchdomain.example.com>
References: <b74c088d-09e6-4842-8b6c-1921d68154c7n@googlegroups.com>
<20230828174502.a279eb2b4ea06fac68dc6561@g{oogle}mail.com>
<e3051618-59e9-453f-a72b-14155a1c46f4n@googlegroups.com>
<uclmau$2d8p3$1@dont-email.me>
<a2f70a58-6b6e-41fd-864a-bcf947bdfdedn@googlegroups.com>
<ucn66n$2n166$1@dont-email.me>
<d500e1f2-7486-4425-a7e2-4472cce70e44n@googlegroups.com>
<ucnl64$2p8as$1@dont-email.me>
<65d28a7d-ffd5-4b8b-b3f0-2500bb05f9b7n@googlegroups.com>
<ucoe3l$2t4o2$1@dont-email.me>
<557bf807-40c7-404b-9242-c26975faa42fn@googlegroups.com>
<ucprpd$38s6i$1@dont-email.me> <ucq1gd$39q14$1@dont-email.me>
<ucq86h$3auvq$1@dont-email.me> <ucqj27$3con1$1@dont-email.me>
<ucqpgp$3dnop$1@dont-email.me> <ucs87g$3n796$1@dont-email.me>
<ucseq9$3o9ic$1@dont-email.me> <20230901102320.265@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="3d717a41e44a951774a492dc9105dbfa";
logging-data="37676"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/pASXRmNK1fvcsuDY3gFPA"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:kUt4boAQ1eLBw1odigs5G1arqBw=
sha1:8U9nx6rUC1M23oatj32iu1Y+OUo=
 by: Keith Thompson - Fri, 1 Sep 2023 21:31 UTC

Kaz Kylheku <864-117-4973@kylheku.com> writes:
> On 2023-09-01, Bart <bc@freeuk.com> wrote:
>> On 01/09/2023 09:43, David Brown wrote:
>>> On 31/08/2023 21:26, Bart wrote:
>>
>>> Putting object files in the current directory is a useful default.
>>
>> 'gcc -c' will do that if the input file is in the same current directory.
>>
>> So if the current directory happens to be /abc, compiling hello.c will
>> produce /abc/hello.o from /abc/hello.c.
>
> You are right. I didn't even notice that or forgot about it all these
> years. -c is only used in very trivial makefiles.
>
> The built-in make recipe doesn't use it; it uses -o so that if you say,
>
> obj/foo.o: src/foo.c
>
> it works fine.
> According to the gcc man page, I would think that
> -c turns src/foo.c into src/foo.o.

Yes, and it works by invoking gcc with the "-c" option, which make knows
how to do.

For GNU make, `make -p` dumps the data base of rules and variable
values. On my system, part of the output is:

COMPILE.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c

Ignoring directory issues, if you want to generate an object file foo.o
from a C source file foo.c, you can use `gcc foo.c -c` or `gcc -c foo.c`
-- or, if you want to be explicit, `gcc foo.c -c -o foo.o`.

If you do `gcc foo.c -o foo.o`, the lack of a `-c` option tells it to
invoke the linker. It will create an executable, not an object file,
named "foo.o". That's very probably not what you want.

> Quote
>
> By default, the object file name for a source file is made by
> replacing the suffix .c, .i, .s, etc., with .o.

I agree that's potentially misleading. I think the intent was that
"object file name" is intended to refer just to the file *name*, not the
full file *path*.

[...]

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

Re: bart again (UCX64)

<uctlpv$17t5$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: bart again (UCX64)
Date: Fri, 1 Sep 2023 22:41:19 +0100
Organization: A noiseless patient Spider
Lines: 56
Message-ID: <uctlpv$17t5$1@dont-email.me>
References: <b74c088d-09e6-4842-8b6c-1921d68154c7n@googlegroups.com>
<ucn66n$2n166$1@dont-email.me>
<d500e1f2-7486-4425-a7e2-4472cce70e44n@googlegroups.com>
<ucnl64$2p8as$1@dont-email.me>
<65d28a7d-ffd5-4b8b-b3f0-2500bb05f9b7n@googlegroups.com>
<ucoe3l$2t4o2$1@dont-email.me>
<557bf807-40c7-404b-9242-c26975faa42fn@googlegroups.com>
<ucprpd$38s6i$1@dont-email.me> <ucq1gd$39q14$1@dont-email.me>
<ucq86h$3auvq$1@dont-email.me> <ucqj27$3con1$1@dont-email.me>
<ucqpgp$3dnop$1@dont-email.me> <aa8IM.249421$f7Ub.27491@fx47.iad>
<ucr3kb$3f58o$1@dont-email.me> <ucs9pb$3nd9i$1@dont-email.me>
<ucsg9u$3ofr6$1@dont-email.me> <20230901104426.371@kylheku.com>
<uct9hv$3v1lb$2@dont-email.me> <20230901114625.198@kylheku.com>
<ucthrb$gvk$2@dont-email.me> <20230901135123.702@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 1 Sep 2023 21:41:19 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="dde9efc24256f8d58e400f7792eddc71";
logging-data="40869"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+4n0fwQAsdPJ/XEuXlXEbynfxjR+rJiTw="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:8Bq+B9ANsUI5rPrb3YyIRKIoMkk=
In-Reply-To: <20230901135123.702@kylheku.com>
 by: Bart - Fri, 1 Sep 2023 21:41 UTC

On 01/09/2023 22:09, Kaz Kylheku wrote:
> On 2023-09-01, Bart <bc@freeuk.com> wrote:
>> On 01/09/2023 19:49, Kaz Kylheku wrote:
>>> On 2023-09-01, Bart <bc@freeuk.com> wrote:
>>>> Is my program correct? Apparently gcc can't tell me; *I* have to tell
>>>> *it*. You pretty much say that above.
>>>
>>> GCC can't tell you whether a program is correct, because it can't read
>>> your requirement specification, high level design or detailed design.
>>> It doesn't run your program, let alone execute test cases on it.
>>>
>>>> OK, *I* say then that if 'gcc prog.c' works with no notes, warnings or
>>>> messages, then my program is fine.
>>>
>>> Even if ./a.out segfaults? Yes, if the requirement specification
>>> for the program is "write me small program that segfaults on Unix".
>>> It would then be incorrect if it terminated normally.
>>>
>>
>> Ok, since you seem determined to misunderstand.
>
> It's you who don't understand what "correct" means.
>
> When you start talking about correctness, the program's specification
> is involved.
>
> In fact that is all that is involved. A null pointer dereference
> or division by zero become correct if the specification says so.
>
>> Is my program a valid C program? The answer seems to depend on a lot
>> more than just the source code submitted.
>
> C is a family of languages with many dialects. An almost fifty-year-old
> family. C++ is a C dialect. Objective C is a C dialect.
>
> What does your question mean?
>
> Does your question mean "is this program a valid program in absolutely
> any C dialect that has ever existed, such that all its externally
> visible behaviors are the same?"

Oh, FFS. We're not talking about C++, or Objective C.

But tell me what dialect of C my 'int fred(void){}' is a valid program
of. Then tell me why most C compilers are still compiling that dialect
by default in 2023.

And now tell me what dialect of C I need for that to be an INvalid program.

It sounds like you're clutching at straws to excuse all this crassness.

Fortran has been around longer than C. Do its latest compilers give
priority to being able to build code unchanged from the 60s and 70s?

Re: bart again (UCX64)

<20230901150200.880@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: bart again (UCX64)
Date: Fri, 1 Sep 2023 22:19:48 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 168
Message-ID: <20230901150200.880@kylheku.com>
References: <b74c088d-09e6-4842-8b6c-1921d68154c7n@googlegroups.com>
<ucn66n$2n166$1@dont-email.me>
<d500e1f2-7486-4425-a7e2-4472cce70e44n@googlegroups.com>
<ucnl64$2p8as$1@dont-email.me>
<65d28a7d-ffd5-4b8b-b3f0-2500bb05f9b7n@googlegroups.com>
<ucoe3l$2t4o2$1@dont-email.me>
<557bf807-40c7-404b-9242-c26975faa42fn@googlegroups.com>
<ucprpd$38s6i$1@dont-email.me> <ucq1gd$39q14$1@dont-email.me>
<ucq86h$3auvq$1@dont-email.me> <ucqj27$3con1$1@dont-email.me>
<ucqpgp$3dnop$1@dont-email.me> <aa8IM.249421$f7Ub.27491@fx47.iad>
<ucr3kb$3f58o$1@dont-email.me> <ucs9pb$3nd9i$1@dont-email.me>
<ucsg9u$3ofr6$1@dont-email.me> <ucsk81$3p2kg$1@dont-email.me>
<ucsm1u$3pb1c$1@dont-email.me> <871qfiknil.fsf@bsb.me.uk>
<ucsu3s$3qfrk$1@dont-email.me> <87v8ctkbsj.fsf@bsb.me.uk>
<uctaf3$3v98j$1@dont-email.me> <20230901115322.184@kylheku.com>
<ucthg8$gvk$1@dont-email.me> <20230901133548.87@kylheku.com>
<uctl33$13ie$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 1 Sep 2023 22:19:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="615329836fb6154f45f8582d7dc5ba06";
logging-data="52059"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/KWaCvkalWzcycfnT7Zw1sq2PBEZ8e3E4="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:9iPPbfvXN36lRrfOfd8MedkMocY=
 by: Kaz Kylheku - Fri, 1 Sep 2023 22:19 UTC

On 2023-09-01, Bart <bc@freeuk.com> wrote:
> On 01/09/2023 21:46, Kaz Kylheku wrote:
>> On 2023-09-01, Bart <bc@freeuk.com> wrote:
>>> MY compilers check that an input sourcefile for language L has a valid
>>> syntax,
>>
>> Which valid syntax? As of the last night's commit which added new
>> syntax?
>>
>> What if I have code that uses last year's syntax, and for the
>> time being want to keep it that way (not have newer syntax
>> creeping in accidentally?)
>>
>> Oh shit! Look, someone likes your language and has written their
>> own implementation. It has a few differences and extensions.
>> Users are starting to use them and complaining they don't work
>> in the original.
>>
>> Do you support those, unconditionally?

Not good at answering the tough questions.
>>
>>> can fully resolve name references, obeys the type rules of the
>>> language, and does various other bits and pieces.
>>
>> Do your compilers target PPC? I have a project that runs on big endian
>> PPC64. Also ported it to Loongarch: this new ISA from China.
>>
>> SPARC? MIPS? RISCV?
>>
>> Oh wait yes; thanks to GCC ...
>>
>>> So how does gcc manage to do pretty much what it likes, including either
>>> compiling a program with no errors or warnings, or compiling the SAME
>>> PROGRAM with fatal errors?
>>
>> By supporting forty years of C revisions, plus its dialect, plus having
>> flexible code generation and diagnosis options, that the users want and
>> depend on.
>
> So you freely admit that C is a mess, and so are its compilers.

Absolutely.

> And yet, it is possible to create a compiler that gives the common-sense
> results that one would expect.

That no one's actual production code base would expect, but go on.

> What do you expect the results of compiling this program with -c to be:
>
> int fred(void){}
>
> Here are the results I get:
>
> Warnings Errors
>
> gcc - -
> tcc - -
> clang 1 -
> msvc 1 -
> gcc -Wall 1 -
> lccwin32 1 -
> bcc - 1
>
>
> The problem with that function, in case you haven't spotted it, is that
> it does not return an 'int' value.

That's a noteworthy fact. If a caller tries to use the return
value, there is a problem.

The C dialect/descendant which makes this an error is C++.

> Yet, not one of those compilers other than bcc stops you creating an
> executable containing a call to that function.

ISO C doesn't require implementations to fail to translate a program,
even if it contains syntax errors and constraint violations that a
conforming implementation must diagnose.
>
> That can be serious, especially if the return type was a pointer.
>
> This is just incredible. You can spout all the nonsense you like about
> the long history of C, but there is no excuse for a compiler in 2023 to
> pass code like that with default behaviour.

There is no excuse for a software engineer to be using a compiler
with default behavior. Not in 2023 or 1993.

> You have to give gcc -Wall to even get it to warn.

So why dontcha?

Wait, check this out. I can out-complain you!

You have to give gc **another c** before it even accepts C programs. That's
how much of a mess it is!

Here is what I get on Ubuntu 18:

$ cat hello.c
#include <stdio.h>

int main(void)
{ puts("hello, world!");
return 0;
} $ gc hello.c
Error: hello.c: syntax error in line 3 near 'int'
$ gcc hello.c
$ ./a.out
hello, world!

Incredible! gc, in its default mode, cannot recognize a valid C program;
emitting bogus diagnostics. We have to add another c.

How do they live with it?

> Yet, everyone here will either defend it to the death, or just brush it
> off and say, Of couse, you have to provide the right options to get the
> compiler to do its job properly.
>
> (BTW, which option do you need to force a hard error on that program,
> which doesn't also fail on unused lables?)

$ gcc -Wall falloff.c -c
falloff.c: In function ‘func’:
falloff.c:1:18: warning: label ‘label’ defined but not used [-Wunused-label]
int func(void) { label: ; }
^~~~~
falloff.c:1:1: warning: control reaches end of non-void function [-Wreturn-type]
int func(void) { label: ; }
^~~

Okay, GCC's friendly diagnosis is telling me that the first warning
is the result of -Wunused-label. Thus:

$ gcc -Wall -Wno-unused-label falloff.c -c
falloff.c: In function ‘func’:
falloff.c:1:1: warning: control reaches end of non-void function [-Wreturn-type]
int func(void) { label: ; }
^~~

Full disclosure: I'm an idiot too, but I have a nephew here who is
starting grade 5 next week who helped me with this!

By the way, in human-written code, you probably want to remove
unused labels.

In generated code, get all your diagnostics from your own front-end,
and operate the C compiler quietly.

> I would say, WHY doesn't it do its job anyway? WHY doesn't it operate in
> a safer mode by default?
>
> I can get my bcc to pass that program, but I have to specify -old, and
> that is only so that existing can be compiled.

-old? What a mess, it's like you have multiple languages in one.

Which one is the real one?

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

Re: bart again (UCX64)

<20230901151959.699@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: bart again (UCX64)
Date: Fri, 1 Sep 2023 22:34:07 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 98
Message-ID: <20230901151959.699@kylheku.com>
References: <b74c088d-09e6-4842-8b6c-1921d68154c7n@googlegroups.com>
<ucn66n$2n166$1@dont-email.me>
<d500e1f2-7486-4425-a7e2-4472cce70e44n@googlegroups.com>
<ucnl64$2p8as$1@dont-email.me>
<65d28a7d-ffd5-4b8b-b3f0-2500bb05f9b7n@googlegroups.com>
<ucoe3l$2t4o2$1@dont-email.me>
<557bf807-40c7-404b-9242-c26975faa42fn@googlegroups.com>
<ucprpd$38s6i$1@dont-email.me> <ucq1gd$39q14$1@dont-email.me>
<ucq86h$3auvq$1@dont-email.me> <ucqj27$3con1$1@dont-email.me>
<ucqpgp$3dnop$1@dont-email.me> <aa8IM.249421$f7Ub.27491@fx47.iad>
<ucr3kb$3f58o$1@dont-email.me> <ucs9pb$3nd9i$1@dont-email.me>
<ucsg9u$3ofr6$1@dont-email.me> <20230901104426.371@kylheku.com>
<uct9hv$3v1lb$2@dont-email.me> <20230901114625.198@kylheku.com>
<ucthrb$gvk$2@dont-email.me> <20230901135123.702@kylheku.com>
<uctlpv$17t5$1@dont-email.me>
Injection-Date: Fri, 1 Sep 2023 22:34:07 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="615329836fb6154f45f8582d7dc5ba06";
logging-data="56814"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/+PpZhGrHlhAYyLxZKbex0+FzIUcU+wCg="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:PlH4B25X00nka9yumsaX/p5x0do=
 by: Kaz Kylheku - Fri, 1 Sep 2023 22:34 UTC

On 2023-09-01, Bart <bc@freeuk.com> wrote:
> On 01/09/2023 22:09, Kaz Kylheku wrote:
>> On 2023-09-01, Bart <bc@freeuk.com> wrote:
>>> On 01/09/2023 19:49, Kaz Kylheku wrote:
>>>> On 2023-09-01, Bart <bc@freeuk.com> wrote:
>>>>> Is my program correct? Apparently gcc can't tell me; *I* have to tell
>>>>> *it*. You pretty much say that above.
>>>>
>>>> GCC can't tell you whether a program is correct, because it can't read
>>>> your requirement specification, high level design or detailed design.
>>>> It doesn't run your program, let alone execute test cases on it.
>>>>
>>>>> OK, *I* say then that if 'gcc prog.c' works with no notes, warnings or
>>>>> messages, then my program is fine.
>>>>
>>>> Even if ./a.out segfaults? Yes, if the requirement specification
>>>> for the program is "write me small program that segfaults on Unix".
>>>> It would then be incorrect if it terminated normally.
>>>>
>>>
>>> Ok, since you seem determined to misunderstand.
>>
>> It's you who don't understand what "correct" means.
>>
>> When you start talking about correctness, the program's specification
>> is involved.
>>
>> In fact that is all that is involved. A null pointer dereference
>> or division by zero become correct if the specification says so.
>>
>>> Is my program a valid C program? The answer seems to depend on a lot
>>> more than just the source code submitted.
>>
>> C is a family of languages with many dialects. An almost fifty-year-old
>> family. C++ is a C dialect. Objective C is a C dialect.
>>
>> What does your question mean?
>>
>> Does your question mean "is this program a valid program in absolutely
>> any C dialect that has ever existed, such that all its externally
>> visible behaviors are the same?"
>
> Oh, FFS. We're not talking about C++, or Objective C.

Those are dialects of C. A program that doesn't compile as C++
isn't "valid C" by the definition of valid in any dialect whatsoever.

> But tell me what dialect of C my 'int fred(void){}' is a valid program
> of.

Right off the bat, it's not valid in anything that is before ANSI C.
Only compilers implementing ANSI C, or at least draft features of ANSI
C, would acdept (void), which is an ANSI C invention.

There are too many dialects of C, including ones I've never heard of, in
which that is potentially valid.

It is valid in C90 and in C99.

> Then tell me why most C compilers are still compiling that dialect
> by default in 2023.

Until quite recently, GCC defaulted to "gnu89": a GNU C dialect
resembling C90/ANSI C. I think it might now be handling "gnu99"
instead.

The C99 dialect of C is very popular; there is a lot of code written
in it.

A dialect based off c99 isn't a bad default choice.

(I think it would be better for gcc to refuse to do anything unless
the dialect is specified.)

> And now tell me what dialect of C I need for that to be an INvalid program.

I don't think the function requires a diagnostic in any standard C
dialect. There is no error unless the caller tries to capture the
return value.

Pretty much any gcc dialect, if given the -Werror=return-type
option rejects it.

That's included in -Wall, so if you use -Werror-all you get that
dialect also.

If you don't want that kind of code in your code base, there
is a solution.

> Fortran has been around longer than C. Do its latest compilers give
> priority to being able to build code unchanged from the 60s and 70s?

I strongly suspect, yes.

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

Re: bart again (UCX64)

<20230901153513.138@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: bart again (UCX64)
Date: Fri, 1 Sep 2023 22:39:43 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <20230901153513.138@kylheku.com>
References: <b74c088d-09e6-4842-8b6c-1921d68154c7n@googlegroups.com>
<20230828174502.a279eb2b4ea06fac68dc6561@g{oogle}mail.com>
<e3051618-59e9-453f-a72b-14155a1c46f4n@googlegroups.com>
<uclmau$2d8p3$1@dont-email.me>
<a2f70a58-6b6e-41fd-864a-bcf947bdfdedn@googlegroups.com>
<ucn66n$2n166$1@dont-email.me>
<d500e1f2-7486-4425-a7e2-4472cce70e44n@googlegroups.com>
<ucnl64$2p8as$1@dont-email.me>
<65d28a7d-ffd5-4b8b-b3f0-2500bb05f9b7n@googlegroups.com>
<ucoe3l$2t4o2$1@dont-email.me>
<557bf807-40c7-404b-9242-c26975faa42fn@googlegroups.com>
<ucprpd$38s6i$1@dont-email.me> <ucq1gd$39q14$1@dont-email.me>
<ucq86h$3auvq$1@dont-email.me> <ucqj27$3con1$1@dont-email.me>
<ucqpgp$3dnop$1@dont-email.me> <ucs87g$3n796$1@dont-email.me>
<ucseq9$3o9ic$1@dont-email.me> <20230901102320.265@kylheku.com>
<87msy57f75.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 1 Sep 2023 22:39:43 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="615329836fb6154f45f8582d7dc5ba06";
logging-data="56814"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/9KaiDrTL+XAWqJjaBxJ6daCagTgBD7DA="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:/Fz4/VB4E9F7Rg8uItRronqZaBA=
 by: Kaz Kylheku - Fri, 1 Sep 2023 22:39 UTC

On 2023-09-01, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
> Kaz Kylheku <864-117-4973@kylheku.com> writes:
>> By default, the object file name for a source file is made by
>> replacing the suffix .c, .i, .s, etc., with .o.
>
> I agree that's potentially misleading. I think the intent was that
> "object file name" is intended to refer just to the file *name*, not the
> full file *path*.

Ah, but I have a piece of trivia for you:

_GNU Coding Standards_, July 1, 2021:

Please do not use the term “pathname” that is used in Unix
documentation; use “file name” (two words) instead. We use the term
“path” only for search paths, which are lists of directory names.

GNU programs and documentation are supposed to use file name
to refer to a path with multiple components too, not just one
component.

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

Re: bart again (UCX64)

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

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: bart again (UCX64)
Date: Fri, 01 Sep 2023 15:51:12 -0700
Organization: None to speak of
Lines: 13
Message-ID: <87cyz17bj3.fsf@nosuchdomain.example.com>
References: <b74c088d-09e6-4842-8b6c-1921d68154c7n@googlegroups.com>
<ucnl64$2p8as$1@dont-email.me>
<65d28a7d-ffd5-4b8b-b3f0-2500bb05f9b7n@googlegroups.com>
<ucoe3l$2t4o2$1@dont-email.me>
<557bf807-40c7-404b-9242-c26975faa42fn@googlegroups.com>
<ucprpd$38s6i$1@dont-email.me> <ucq1gd$39q14$1@dont-email.me>
<ucq86h$3auvq$1@dont-email.me> <ucqj27$3con1$1@dont-email.me>
<ucqpgp$3dnop$1@dont-email.me> <aa8IM.249421$f7Ub.27491@fx47.iad>
<ucr3kb$3f58o$1@dont-email.me> <ucs9pb$3nd9i$1@dont-email.me>
<ucsg9u$3ofr6$1@dont-email.me> <20230901104426.371@kylheku.com>
<uct9hv$3v1lb$2@dont-email.me> <20230901114625.198@kylheku.com>
<ucthrb$gvk$2@dont-email.me> <20230901135123.702@kylheku.com>
<uctlpv$17t5$1@dont-email.me> <20230901151959.699@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="5bc2673ae158b6c9ff051aa9353664b0";
logging-data="57466"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+eLCpXFuZAdWbdSjn8ZKHY"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:erdNn0sRmDfrt2COWosf5u5tns0=
sha1:DXTBw357+2+dM4hiIP2om1OwecA=
 by: Keith Thompson - Fri, 1 Sep 2023 22:51 UTC

Kaz Kylheku <864-117-4973@kylheku.com> writes:
[...]
> Until quite recently, GCC defaulted to "gnu89": a GNU C dialect
> resembling C90/ANSI C. I think it might now be handling "gnu99"
> instead.
[...]

Recent versions of gcc default to "-std=gnu17".

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

Re: bart again (UCX64)

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

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: bart again (UCX64)
Date: Fri, 01 Sep 2023 16:02:00 -0700
Organization: None to speak of
Lines: 31
Message-ID: <878r9p7b13.fsf@nosuchdomain.example.com>
References: <b74c088d-09e6-4842-8b6c-1921d68154c7n@googlegroups.com>
<d500e1f2-7486-4425-a7e2-4472cce70e44n@googlegroups.com>
<ucnl64$2p8as$1@dont-email.me>
<65d28a7d-ffd5-4b8b-b3f0-2500bb05f9b7n@googlegroups.com>
<ucoe3l$2t4o2$1@dont-email.me>
<557bf807-40c7-404b-9242-c26975faa42fn@googlegroups.com>
<ucprpd$38s6i$1@dont-email.me> <ucq1gd$39q14$1@dont-email.me>
<ucq86h$3auvq$1@dont-email.me> <ucqj27$3con1$1@dont-email.me>
<ucqpgp$3dnop$1@dont-email.me> <aa8IM.249421$f7Ub.27491@fx47.iad>
<ucr3kb$3f58o$1@dont-email.me> <ucs9pb$3nd9i$1@dont-email.me>
<ucsg9u$3ofr6$1@dont-email.me> <20230901104426.371@kylheku.com>
<uct9hv$3v1lb$2@dont-email.me> <20230901114625.198@kylheku.com>
<ucthrb$gvk$2@dont-email.me> <20230901135123.702@kylheku.com>
<uctlpv$17t5$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="5bc2673ae158b6c9ff051aa9353664b0";
logging-data="64296"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/b78vv68XB9FsJR3KuByHm"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:ehjWEIFPSs2MOylJU97LJeC2VYs=
sha1:GFGD5E2Sn0m/He+X+RkuEmXoBzA=
 by: Keith Thompson - Fri, 1 Sep 2023 23:02 UTC

Bart <bc@freeuk.com> writes:
[...]
> But tell me what dialect of C my 'int fred(void){}' is a valid program
> of. Then tell me why most C compilers are still compiling that dialect
> by default in 2023.
[...]

Can you clarify what point you're making with `int fred(void){}`?

That's a valid function definition and translation unit in every version
of ISO C going back to C90, by which I mean that it does not violate any
constraint or syntax rule. (I presume we're not concerned with K&R C,
which didn't have void.) It is not a valid *program* for a hosted
implementation in any version of C, since it lacks a `main` function.

A compiler may reasonably warn about the fact that control reaches the
end of a non-void function, but the standard doesn't require a
diagnostic. Calling `fred` and not using the result is well defined.
Calling `fred` and attempting to use the result has undefined behavior.
No diagnostic is required, up to and including C23. (There are
historical reasons for this, which I won't go into.)

Note carefully that I am describing the requirements given by the C
standard, not expressing an opinion on whether they're good or bad.

Now, what was your point, and how does `int fred(void){}` illustrate it?

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

Re: bart again (UCX64)

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

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: bart again (UCX64)
Date: Sat, 02 Sep 2023 01:14:21 +0100
Organization: A noiseless patient Spider
Lines: 54
Message-ID: <87pm31jusi.fsf@bsb.me.uk>
References: <b74c088d-09e6-4842-8b6c-1921d68154c7n@googlegroups.com>
<d500e1f2-7486-4425-a7e2-4472cce70e44n@googlegroups.com>
<ucnl64$2p8as$1@dont-email.me>
<65d28a7d-ffd5-4b8b-b3f0-2500bb05f9b7n@googlegroups.com>
<ucoe3l$2t4o2$1@dont-email.me>
<557bf807-40c7-404b-9242-c26975faa42fn@googlegroups.com>
<ucprpd$38s6i$1@dont-email.me> <ucq1gd$39q14$1@dont-email.me>
<ucq86h$3auvq$1@dont-email.me> <ucqj27$3con1$1@dont-email.me>
<ucqpgp$3dnop$1@dont-email.me> <aa8IM.249421$f7Ub.27491@fx47.iad>
<ucr3kb$3f58o$1@dont-email.me> <ucs9pb$3nd9i$1@dont-email.me>
<ucsg9u$3ofr6$1@dont-email.me> <ucsk81$3p2kg$1@dont-email.me>
<ucsm1u$3pb1c$1@dont-email.me> <871qfiknil.fsf@bsb.me.uk>
<ucsu3s$3qfrk$1@dont-email.me> <87v8ctkbsj.fsf@bsb.me.uk>
<uctaf3$3v98j$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="69fd406a6512410fffc0c90dd9eb917a";
logging-data="80929"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18yvgl/vCmj6FfOeYMHyAyyeumAKo/Jeig="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:Tkczz4xJUxIPmSkUFjueNMb4DzY=
sha1:C5jsgDyWhWKfOqLNdw18X4FQ6Ew=
X-BSB-Auth: 1.b3046a828b333db2e421.20230902011421BST.87pm31jusi.fsf@bsb.me.uk
 by: Ben Bacarisse - Sat, 2 Sep 2023 00:14 UTC

Bart <bc@freeuk.com> writes:

> On 01/09/2023 19:07, Ben Bacarisse wrote:
>> Bart <bc@freeuk.com> writes:
>>
>>> On 01/09/2023 14:53, Ben Bacarisse wrote:
>>>> Bart <bc@freeuk.com> writes:
>>>>
>>>>> On 01/09/2023 13:08, Richard Harnden wrote:
>>>>>> On 01/09/2023 12:01, Bart wrote:
>>>>
>>>>>>> We are talking about compilers like gcc where you make up your own rules
>>>>>>> as to show strictly you want your program treated:
>>>>>>>
>>>>>>>   gcc prog.c              zero warnings, writes .exe
>>>>>>>   gcc @options prog.c     10000 warnings, but it still writes .exe
>>>>>>>   gcc @options prog.c     10000 warning and 1 error, no .exe
>>>>
>>>> Which would you choose as the one and only behaviour?
>> No answer? I'll look at the rest of your post, if you decide to address
>> this point...

> You want an answer, I'd go with the first, since then the three compilers I
> use the most work the same way.
>
> That's not completely satisfactory,

It's totally unacceptable to me and, I suspect, a lot of other people.
I usually don't want gcc extensions and I want to be able specify the
ISO C standard to use at the very least. But I also want as much help
spotting errors as the compiler can give me.

> since there are aspects of the C language I think are too unsafe, but:
>
> * Have to be passed because they are legal C
>
> * Cannot reliably be detected by a compiler
>
> * Are too extensively used in legacy code to be just outlawed.

Yet you want to stop people from having hundreds of helpful diagnostics.

I suspect you don't mean what you seem to have said -- that gcc should
always behave in it's default mode. But if that is not what you meant
to say then you have not answered the question at all.

You say, dismissively, that one can "make up ones your rules" with gcc,
so I am asking for you to say exactly what you don't want me to be able
to ask for in terms of checking and/or its absence. Just how crippled
and annoying would I find gcc to be if you were in charge? How much
choice will you take away?

--
Ben.

Re: bart again (UCX64)

<ucu0tf$2mht$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: bart again (UCX64)
Date: Sat, 2 Sep 2023 01:50:54 +0100
Organization: A noiseless patient Spider
Lines: 84
Message-ID: <ucu0tf$2mht$1@dont-email.me>
References: <b74c088d-09e6-4842-8b6c-1921d68154c7n@googlegroups.com>
<d500e1f2-7486-4425-a7e2-4472cce70e44n@googlegroups.com>
<ucnl64$2p8as$1@dont-email.me>
<65d28a7d-ffd5-4b8b-b3f0-2500bb05f9b7n@googlegroups.com>
<ucoe3l$2t4o2$1@dont-email.me>
<557bf807-40c7-404b-9242-c26975faa42fn@googlegroups.com>
<ucprpd$38s6i$1@dont-email.me> <ucq1gd$39q14$1@dont-email.me>
<ucq86h$3auvq$1@dont-email.me> <ucqj27$3con1$1@dont-email.me>
<ucqpgp$3dnop$1@dont-email.me> <aa8IM.249421$f7Ub.27491@fx47.iad>
<ucr3kb$3f58o$1@dont-email.me> <ucs9pb$3nd9i$1@dont-email.me>
<ucsg9u$3ofr6$1@dont-email.me> <20230901104426.371@kylheku.com>
<uct9hv$3v1lb$2@dont-email.me> <20230901114625.198@kylheku.com>
<ucthrb$gvk$2@dont-email.me> <20230901135123.702@kylheku.com>
<uctlpv$17t5$1@dont-email.me> <878r9p7b13.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 2 Sep 2023 00:50:55 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6819b4a109914e1bed6fb9e7146da526";
logging-data="88637"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18WeN9lAXPysrLQWwtiK+voDWRWicbgy1I="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:WmhcSNqimLQcCCKyk8s7tGdEJNA=
In-Reply-To: <878r9p7b13.fsf@nosuchdomain.example.com>
 by: Bart - Sat, 2 Sep 2023 00:50 UTC

On 02/09/2023 00:02, Keith Thompson wrote:
> Bart <bc@freeuk.com> writes:
> [...]
>> But tell me what dialect of C my 'int fred(void){}' is a valid program
>> of. Then tell me why most C compilers are still compiling that dialect
>> by default in 2023.
> [...]
>
> Can you clarify what point you're making with `int fred(void){}`?
>
> That's a valid function definition and translation unit in every version
> of ISO C going back to C90, by which I mean that it does not violate any
> constraint or syntax rule. (I presume we're not concerned with K&R C,
> which didn't have void.) It is not a valid *program* for a hosted
> implementation in any version of C, since it lacks a `main` function.
>
> A compiler may reasonably warn about the fact that control reaches the
> end of a non-void function, but the standard doesn't require a
> diagnostic. Calling `fred` and not using the result is well defined.
> Calling `fred` and attempting to use the result has undefined behavior.
> No diagnostic is required, up to and including C23. (There are
> historical reasons for this, which I won't go into.)
>
> Note carefully that I am describing the requirements given by the C
> standard, not expressing an opinion on whether they're good or bad.
>
> Now, what was your point, and how does `int fred(void){}` illustrate it?

I would have said it's obviously wrong.

But in this group, so many people have argued that black is white, or
vice versa, that nothing surprises me any more.

Imagine buying a car with no brakes. Oh, nothing wrong that, only if you
were to actually use the brakes! Then, it would have been up to me to
insist on having brakes in the first place, something I wouldn't have
thought was my responsibility.

This either really is that crazy, or everyone is in on a conspiracy to
wind me up.

> A compiler may reasonably warn about the fact that control reaches the
> end of a non-void function,

Why only warn? This should be a hard error. Fix it and move on.

> Calling `fred` and not using the result is well defined.

People say C is unsafe. Yes it is, but this nonsense makes it extra
unsafe for no good reason.

Suppose fred() is part of a library. Then who knows what code will be
calling it and whether that value is expected.

What possible point, what advantage, is there in defining a function's
return type, but not providing any value?

Look, I promised this guy I would overhaul at my C compiler. Fortunately
the task is interesting, and for now, it doesn't involving dealing with
much C code.

Otherwise, this crazy language, crazy compilers, crazy tools and the
crazy opinions of its adherents are seriously doing my head in.

I've given staggeringly bad examples of each, but nobody is fazed.
There's always some excuse. And if there is no actual reason, it's
because it's how it worked in 1974 so it has to be like that for eternity.

I'm going back to my own saner language and compilers that don't beat
about the bush:

func fred:int =
end

"Return value missing"

I can't proceed until I provide one, or change it to a function that
doesn't return a value.

Is there ... anything wrong with that?

Re: bart again (UCX64)

<20230901175635.91@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: bart again (UCX64)
Date: Sat, 2 Sep 2023 01:12:33 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 72
Message-ID: <20230901175635.91@kylheku.com>
References: <b74c088d-09e6-4842-8b6c-1921d68154c7n@googlegroups.com>
<d500e1f2-7486-4425-a7e2-4472cce70e44n@googlegroups.com>
<ucnl64$2p8as$1@dont-email.me>
<65d28a7d-ffd5-4b8b-b3f0-2500bb05f9b7n@googlegroups.com>
<ucoe3l$2t4o2$1@dont-email.me>
<557bf807-40c7-404b-9242-c26975faa42fn@googlegroups.com>
<ucprpd$38s6i$1@dont-email.me> <ucq1gd$39q14$1@dont-email.me>
<ucq86h$3auvq$1@dont-email.me> <ucqj27$3con1$1@dont-email.me>
<ucqpgp$3dnop$1@dont-email.me> <aa8IM.249421$f7Ub.27491@fx47.iad>
<ucr3kb$3f58o$1@dont-email.me> <ucs9pb$3nd9i$1@dont-email.me>
<ucsg9u$3ofr6$1@dont-email.me> <20230901104426.371@kylheku.com>
<uct9hv$3v1lb$2@dont-email.me> <20230901114625.198@kylheku.com>
<ucthrb$gvk$2@dont-email.me> <20230901135123.702@kylheku.com>
<uctlpv$17t5$1@dont-email.me> <878r9p7b13.fsf@nosuchdomain.example.com>
<ucu0tf$2mht$1@dont-email.me>
Injection-Date: Sat, 2 Sep 2023 01:12:33 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="615329836fb6154f45f8582d7dc5ba06";
logging-data="93102"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19g5CsD+N6FxMzGyfZYe8NFL6o1D0OXPZE="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:e0x06pkXa/xeqtYjACC6CtUf0zE=
 by: Kaz Kylheku - Sat, 2 Sep 2023 01:12 UTC

On 2023-09-02, Bart <bc@freeuk.com> wrote:
> On 02/09/2023 00:02, Keith Thompson wrote:
>> Now, what was your point, and how does `int fred(void){}` illustrate it?
>
> I would have said it's obviously wrong.
>
> But in this group, so many people have argued that black is white, or
> vice versa, that nothing surprises me any more.

It's a good idea to produce a diagnostic in cases when it's obvious
that the control graph of the function reaches the end without
hitting a return statement.

C allowing the return, provided that the caller doesn't use the
value, is a bit of a relic. Early C worked that way because
every function returned int, but not every function needed
to return anything. It's not a good feature today.

Keith seems to have mentioned that something had been done about it
in C23?

Anyway, compilers can diagnose it even though it's not required.

It would be significantly more difficult to work with C without
compilers that go beyond required diagnostics.

You can't just blindly diagnose this as a syntactic issue; i.e.
that the last statement of a function which returns a value isn't
a return statement.

We don't want this diagnosed:

int fred(void)
{
if (this)
return that;
else
return other;
}

Basically we want the last statement to to be a "tail statement",
which is defined as a return statement, or else a statement which
has a tail statement in every tail position.

The body of a loop is a tail statement if there is no break or goto out
of it.

A loop is a tail statement if its guard is a constant expression
evaluating to true.

A function call is a tail statement if it calls a function known
not to return: abort(), longjmp(), exit() and some others.

> Imagine buying a car with no brakes. Oh, nothing wrong that, only if you

Imagine buying a power transistor with no thermal shutoff.

Wait, that's pretty much all of them.

Engineering products and consumer products are different.

A transistor has good reasons for being the way it is; a language
allowing control flow to fall off the end without a return value
isn't such a good reason. We can't compare the justification.

It's still an engineering tool with a "safe operating area"
that you have to observe, and not comparable to a consumer product.

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

Re: bart again (UCX64)

<2711a385-0bd0-4d0b-8f9a-1cdcf8682586n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:43:b0:40b:2fd7:55a8 with SMTP id y3-20020a05622a004300b0040b2fd755a8mr95621qtw.8.1693617193684;
Fri, 01 Sep 2023 18:13:13 -0700 (PDT)
X-Received: by 2002:a63:925e:0:b0:565:eb51:3866 with SMTP id
s30-20020a63925e000000b00565eb513866mr841929pgn.11.1693617193125; Fri, 01 Sep
2023 18:13:13 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Fri, 1 Sep 2023 18:13:12 -0700 (PDT)
In-Reply-To: <87pm31jusi.fsf@bsb.me.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:d1a7:af75:4963:9499;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:d1a7:af75:4963:9499
References: <b74c088d-09e6-4842-8b6c-1921d68154c7n@googlegroups.com>
<d500e1f2-7486-4425-a7e2-4472cce70e44n@googlegroups.com> <ucnl64$2p8as$1@dont-email.me>
<65d28a7d-ffd5-4b8b-b3f0-2500bb05f9b7n@googlegroups.com> <ucoe3l$2t4o2$1@dont-email.me>
<557bf807-40c7-404b-9242-c26975faa42fn@googlegroups.com> <ucprpd$38s6i$1@dont-email.me>
<ucq1gd$39q14$1@dont-email.me> <ucq86h$3auvq$1@dont-email.me>
<ucqj27$3con1$1@dont-email.me> <ucqpgp$3dnop$1@dont-email.me>
<aa8IM.249421$f7Ub.27491@fx47.iad> <ucr3kb$3f58o$1@dont-email.me>
<ucs9pb$3nd9i$1@dont-email.me> <ucsg9u$3ofr6$1@dont-email.me>
<ucsk81$3p2kg$1@dont-email.me> <ucsm1u$3pb1c$1@dont-email.me>
<871qfiknil.fsf@bsb.me.uk> <ucsu3s$3qfrk$1@dont-email.me> <87v8ctkbsj.fsf@bsb.me.uk>
<uctaf3$3v98j$1@dont-email.me> <87pm31jusi.fsf@bsb.me.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2711a385-0bd0-4d0b-8f9a-1cdcf8682586n@googlegroups.com>
Subject: Re: bart again (UCX64)
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Sat, 02 Sep 2023 01:13:13 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 5614
 by: Malcolm McLean - Sat, 2 Sep 2023 01:13 UTC

On Saturday, 2 September 2023 at 01:14:36 UTC+1, Ben Bacarisse wrote:
> Bart <b...@freeuk.com> writes:
>
> > On 01/09/2023 19:07, Ben Bacarisse wrote:
> >> Bart <b...@freeuk.com> writes:
> >>
> >>> On 01/09/2023 14:53, Ben Bacarisse wrote:
> >>>> Bart <b...@freeuk.com> writes:
> >>>>
> >>>>> On 01/09/2023 13:08, Richard Harnden wrote:
> >>>>>> On 01/09/2023 12:01, Bart wrote:
> >>>>
> >>>>>>> We are talking about compilers like gcc where you make up your own rules
> >>>>>>> as to show strictly you want your program treated:
> >>>>>>>
> >>>>>>> gcc prog.c zero warnings, writes .exe
> >>>>>>> gcc @options prog.c 10000 warnings, but it still writes .exe
> >>>>>>> gcc @options prog.c 10000 warning and 1 error, no .exe
> >>>>
> >>>> Which would you choose as the one and only behaviour?
> >> No answer? I'll look at the rest of your post, if you decide to address
> >> this point...
> > You want an answer, I'd go with the first, since then the three compilers I
> > use the most work the same way.
> >
> > That's not completely satisfactory,
> It's totally unacceptable to me and, I suspect, a lot of other people.
> I usually don't want gcc extensions and I want to be able specify the
> ISO C standard to use at the very least. But I also want as much help
> spotting errors as the compiler can give me.
>
Generally gcc in default mode gives sensible warnings which either indicate
actual bugs, or odd programming which should be cleaned up. Then you can
ramp up the warning level to get a huge amount, but they tend to be things
like warnings about mixed mode arithemetic because size_t is unsigned,
which is very unlikely to cause an error.
>
> > since there are aspects of the C language I think are too unsafe, but:
> >
> > * Have to be passed because they are legal C
> >
> > * Cannot reliably be detected by a compiler
> >
> > * Are too extensively used in legacy code to be just outlawed.
> Yet you want to stop people from having hundreds of helpful diagnostics.
>
> I suspect you don't mean what you seem to have said -- that gcc should
> always behave in it's default mode. But if that is not what you meant
> to say then you have not answered the question at all.
>
> You say, dismissively, that one can "make up ones your rules" with gcc,
> so I am asking for you to say exactly what you don't want me to be able
> to ask for in terms of checking and/or its absence. Just how crippled
> and annoying would I find gcc to be if you were in charge? How much
> choice will you take away?
>
In most software, every option you provide represents a failure rather than
an enhancement. It's often a symptom of sloppy design - a lot of functions
need parameterising, and instead of doing the hard work and finding the
parameters to use, the designer just gives the job to the user. It's often a
symptom of design by programmers rather than user-interface people.
Programmers don't mind -gamma-correction=1.1, but it's a nightmare to
someone who just wants to watch telly. I suppose you could argue that a
compiler is an exception to the general rule that programmers shouldn't design
interfaces.
But the general rule is that options make a program easier to write and harder
to use. Sometimes the gain in ease of writing is so large that a small loss
in ease of use has to be tolerated. And of course there is the issue of what is
an "option" and what is a regular instruction to the program that inherently
has to come from the user.
But basically a compiler should translate C source to object code. That's
all it should do. And it shouldn't need telling how to do that.

Re: bart again (UCX64)

<20230901183816.230@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: bart again (UCX64)
Date: Sat, 2 Sep 2023 01:43:00 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <20230901183816.230@kylheku.com>
References: <b74c088d-09e6-4842-8b6c-1921d68154c7n@googlegroups.com>
<d500e1f2-7486-4425-a7e2-4472cce70e44n@googlegroups.com>
<ucnl64$2p8as$1@dont-email.me>
<65d28a7d-ffd5-4b8b-b3f0-2500bb05f9b7n@googlegroups.com>
<ucoe3l$2t4o2$1@dont-email.me>
<557bf807-40c7-404b-9242-c26975faa42fn@googlegroups.com>
<ucprpd$38s6i$1@dont-email.me> <ucq1gd$39q14$1@dont-email.me>
<ucq86h$3auvq$1@dont-email.me> <ucqj27$3con1$1@dont-email.me>
<ucqpgp$3dnop$1@dont-email.me> <aa8IM.249421$f7Ub.27491@fx47.iad>
<ucr3kb$3f58o$1@dont-email.me> <ucs9pb$3nd9i$1@dont-email.me>
<ucsg9u$3ofr6$1@dont-email.me> <ucsk81$3p2kg$1@dont-email.me>
<ucsm1u$3pb1c$1@dont-email.me> <871qfiknil.fsf@bsb.me.uk>
<ucsu3s$3qfrk$1@dont-email.me> <87v8ctkbsj.fsf@bsb.me.uk>
<uctaf3$3v98j$1@dont-email.me> <87pm31jusi.fsf@bsb.me.uk>
<2711a385-0bd0-4d0b-8f9a-1cdcf8682586n@googlegroups.com>
Injection-Date: Sat, 2 Sep 2023 01:43:00 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="615329836fb6154f45f8582d7dc5ba06";
logging-data="222372"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+0s+7i8P2rig7T/5g/4m3PkGoBWNYKOJw="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:OJIYNjlZkdJhBnoL1KFEiuWFRos=
 by: Kaz Kylheku - Sat, 2 Sep 2023 01:43 UTC

On 2023-09-02, Malcolm McLean <malcolm.arthur.mclean@gmail.com> wrote:
> Generally gcc in default mode gives sensible warnings which either indicate

For values of "default mode" being -Wall, of course.

> In most software, every option you provide represents a failure rather than
> an enhancement. It's often a symptom of sloppy design - a lot of functions
> need parameterising, and instead of doing the hard work and finding the
> parameters to use, the designer just gives the job to the user. It's often a
> symptom of design by programmers rather than user-interface people.

But that's what a programming language is.

The vendor describes some assembly language instructions described in
the data sheet for the chip, effectively punting to the user the
task of deciding which ones to select in order to have it Pac Man.

A piano is nothing but sloppy design; you have to pick a sequence
of correct notes out of 88 keys. At least they have player pianos
though.

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

Re: bart again (UCX64)

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

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: bart again (UCX64)
Date: Fri, 01 Sep 2023 19:02:55 -0700
Organization: None to speak of
Lines: 81
Message-ID: <877cp98h80.fsf@nosuchdomain.example.com>
References: <b74c088d-09e6-4842-8b6c-1921d68154c7n@googlegroups.com>
<65d28a7d-ffd5-4b8b-b3f0-2500bb05f9b7n@googlegroups.com>
<ucoe3l$2t4o2$1@dont-email.me>
<557bf807-40c7-404b-9242-c26975faa42fn@googlegroups.com>
<ucprpd$38s6i$1@dont-email.me> <ucq1gd$39q14$1@dont-email.me>
<ucq86h$3auvq$1@dont-email.me> <ucqj27$3con1$1@dont-email.me>
<ucqpgp$3dnop$1@dont-email.me> <aa8IM.249421$f7Ub.27491@fx47.iad>
<ucr3kb$3f58o$1@dont-email.me> <ucs9pb$3nd9i$1@dont-email.me>
<ucsg9u$3ofr6$1@dont-email.me> <20230901104426.371@kylheku.com>
<uct9hv$3v1lb$2@dont-email.me> <20230901114625.198@kylheku.com>
<ucthrb$gvk$2@dont-email.me> <20230901135123.702@kylheku.com>
<uctlpv$17t5$1@dont-email.me>
<878r9p7b13.fsf@nosuchdomain.example.com>
<ucu0tf$2mht$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="5bc2673ae158b6c9ff051aa9353664b0";
logging-data="228573"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19eDSJ3R5PKipGydK5DbNBJ"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:MAp6PBjxmVPlVrFJ0drFkOrtVi8=
sha1:9+EAiAU/lgeCcJjpfUxTeziN9sY=
 by: Keith Thompson - Sat, 2 Sep 2023 02:02 UTC

Bart <bc@freeuk.com> writes:
> On 02/09/2023 00:02, Keith Thompson wrote:
>> Bart <bc@freeuk.com> writes:
>> [...]
>>> But tell me what dialect of C my 'int fred(void){}' is a valid program
>>> of. Then tell me why most C compilers are still compiling that dialect
>>> by default in 2023.
>> [...]
>> Can you clarify what point you're making with `int fred(void){}`?
>> That's a valid function definition and translation unit in every
>> version
>> of ISO C going back to C90, by which I mean that it does not violate any
>> constraint or syntax rule. (I presume we're not concerned with K&R C,
>> which didn't have void.) It is not a valid *program* for a hosted
>> implementation in any version of C, since it lacks a `main` function.
>> A compiler may reasonably warn about the fact that control reaches
>> the
>> end of a non-void function, but the standard doesn't require a
>> diagnostic. Calling `fred` and not using the result is well defined.
>> Calling `fred` and attempting to use the result has undefined behavior.
>> No diagnostic is required, up to and including C23. (There are
>> historical reasons for this, which I won't go into.)
>> Note carefully that I am describing the requirements given by the C
>> standard, not expressing an opinion on whether they're good or bad.
>> Now, what was your point, and how does `int fred(void){}` illustrate
>> it?
>
> I would have said it's obviously wrong.

Reading the rest of your reply, it takes you several paragraphs to get
around to saying *why* it's "obviously wrong". You think it's obviously
wrong because it's defined to return a non-void, but it does not do so.

I mentioned that there are historical reasons why this is not a fatal
error. I've probably discussed those reasons here before, though not in
this thread. If I thought you were interested in learning something,
I'd be glad to do so again. If someone else asks I'll explain it to
them, and you can read along if you like.

It is a fact that `int fred(void){}` does not, according to any edition
of the ISO C standard, require a diagnostic. It does not violate any
syntax rule or constraint.

I don't know how to make it any clearer that I was explaining to you
what the standard says, not expressing or soliciting an opinion about
it.

> But in this group, so many people have argued that black is white, or
> vice versa, that nothing surprises me any more.

If you're saying that I'm wrong about what the standard says, I'm
interested in hearing why.

Am I wrong about what the standard says?

If you're saying that you don't like what the standard says, I'm aware
of that and profoundly uninterested in discussing it with you.

And of course gcc can be made to warn about it with the right options.

[...]

> I'm going back to my own saner language and compilers that don't beat
> about the bush:
>
> func fred:int =
> end
>
> "Return value missing"
>
> I can't proceed until I provide one, or change it to a function that
> doesn't return a value.
>
> Is there ... anything wrong with that?

No, and I have never said or implied that there is. But you know that.

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

Re: bart again (UCX64)

<8734zx8gpv.fsf@nosuchdomain.example.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: bart again (UCX64)
Date: Fri, 01 Sep 2023 19:13:48 -0700
Organization: None to speak of
Lines: 66
Message-ID: <8734zx8gpv.fsf@nosuchdomain.example.com>
References: <b74c088d-09e6-4842-8b6c-1921d68154c7n@googlegroups.com>
<ucoe3l$2t4o2$1@dont-email.me>
<557bf807-40c7-404b-9242-c26975faa42fn@googlegroups.com>
<ucprpd$38s6i$1@dont-email.me> <ucq1gd$39q14$1@dont-email.me>
<ucq86h$3auvq$1@dont-email.me> <ucqj27$3con1$1@dont-email.me>
<ucqpgp$3dnop$1@dont-email.me> <aa8IM.249421$f7Ub.27491@fx47.iad>
<ucr3kb$3f58o$1@dont-email.me> <ucs9pb$3nd9i$1@dont-email.me>
<ucsg9u$3ofr6$1@dont-email.me> <20230901104426.371@kylheku.com>
<uct9hv$3v1lb$2@dont-email.me> <20230901114625.198@kylheku.com>
<ucthrb$gvk$2@dont-email.me> <20230901135123.702@kylheku.com>
<uctlpv$17t5$1@dont-email.me>
<878r9p7b13.fsf@nosuchdomain.example.com>
<ucu0tf$2mht$1@dont-email.me> <20230901175635.91@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="5bc2673ae158b6c9ff051aa9353664b0";
logging-data="231112"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Mt4uus8gDp+PTdbJl9SK/"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:4Qa4YepvxFi3mnzereHDgjQiDh0=
sha1:EnzOFTlBKMaUvpFKfQnsnW7QI64=
 by: Keith Thompson - Sat, 2 Sep 2023 02:13 UTC

Kaz Kylheku <864-117-4973@kylheku.com> writes:
[...]
> C allowing the return, provided that the caller doesn't use the
> value, is a bit of a relic. Early C worked that way because
> every function returned int, but not every function needed
> to return anything. It's not a good feature today.
>
> Keith seems to have mentioned that something had been done about it
> in C23?

No, it's the same in C23.

N3096 6.9.1p12:

Unless otherwise specified, if the } that terminates the function
body is reached, and the value of the function call is used by the
caller, the behavior is undefined.

I think the "unles otherwise specified" refers to the special case rule
for falling off the end of main().

> Anyway, compilers can diagnose it even though it's not required.
>
> It would be significantly more difficult to work with C without
> compilers that go beyond required diagnostics.
>
> You can't just blindly diagnose this as a syntactic issue; i.e.
> that the last statement of a function which returns a value isn't
> a return statement.
>
> We don't want this diagnosed:
>
> int fred(void)
> {
> if (this)
> return that;
> else
> return other;
> }
>
> Basically we want the last statement to to be a "tail statement",
> which is defined as a return statement, or else a statement which
> has a tail statement in every tail position.
>
> The body of a loop is a tail statement if there is no break or goto out
> of it.
>
> A loop is a tail statement if its guard is a constant expression
> evaluating to true.
>
> A function call is a tail statement if it calls a function known
> not to return: abort(), longjmp(), exit() and some others.
[...]

To put it another way, the closing } of a non-void function (other
than main()) should be unreachable.

When C was first defined, and probably as late as 1989, it would
(arguably) have been unreasonable to require all C compilers to
do the kind of analysis needed to enforce this. Some more modern
languages do have requirement like this.

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


devel / comp.lang.c / Re: bart again (UCX64)

Pages:12345678910111213141516
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor