Sujet : Re: Bart's Language
De : antispam (at) *nospam* fricas.org (Waldek Hebisch)
Groupes : comp.lang.cDate : 22. Mar 2025, 15:37:34
Autres entêtes
Organisation : To protect and to server
Message-ID : <vrmhvc$2nif7$3@paganini.bofh.team>
References : 1 2 3 4 5 6 7
User-Agent : tin/2.6.2-20221225 ("Pittyvaich") (Linux/6.1.0-9-amd64 (x86_64))
Keith Thompson <Keith.S.Thompson+
u@gmail.com> wrote:
antispam@fricas.org (Waldek Hebisch) writes:
[...]
Well, it is rather easy to see if variable is used within its
own initialization, so practically it is minor gap. Of course,
there is problem with C standard: IIUC depending on rest of
the code declarations as above are merely undefined behaviour
or even produce unspecified value. So C compiler is
forbidden to stop compilation are report compile time error.
Valid responses to undefined behavior include "terminating a translation
or execution (with the issuance of a diagnostic message)". In other
words, if a compiler is able to prove that a program has undefined
behavior (that will occur on each execution), it can reject it at
compile time.
This was probably subject to previous disscussion here, IIRC
some posters here claimed that even in such case implementation
is supposed to produce an executable. However, certainly
implementation must accept the program when code that would
exhibit undefined behaviour is not executed. And in practice
when using separate compilation compiler normally is not
able to decide if a function will be called or not (and even
when whole program is available compiler still have halting
problem to solve). So cases when compiler is allowed to report
compilation error are quite limite in practice.
So, putting a constraint on self reference in initialization
would improve error detection in C compilers. And of course
languages that what to be better than C should avoid C
mistake.
-- Waldek Hebisch