Sujet : Re: Loops (was Re: do { quit; } else { })
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.cDate : 12. May 2025, 03:09:03
Autres entêtes
Organisation : None to speak of
Message-ID : <87jz6m4m2o.fsf@nosuchdomain.example.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
User-Agent : Gnus/5.13 (Gnus v5.13)
Tim Rentsch <
tr.17687@z991.linuxsc.com> writes:
Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
James Kuyper <jameskuyper@alumni.caltech.edu> writes:
[...]
>
It's main potential usefulness is not in the definition of the
function, but in calls to the function. If the calls occur in
a different translation unit from the definition, the compiler
does not have the needed information.
>
It does if the visible declaration has the same information.
>
Like 'restrict', parameter array length information, specified by
way of 'static', is ignored outside of function definitions. As
was intended (with 'restrict' also).
I think that by "is ignored", you mean that compilers are not
required to pay attention to it. But in fact both gcc and clang
issue (non-required) warnings in some cases where it's appropriate,
based in information given by "[static N]". "[static 1]" can be
used to require that the argument must be non-null (with UB if the
requirement is violated).
Furthermore, and also like 'restrict', there is no general
way to verify at compile time that the stipulated condition
holds.
Right, but that doesn't prevent implementations from issuing useful
warnings when it can determine that the stipulated condition does not
hold.
Considering the above, it's better to observe the status quo, and
leave any diagnostics up to the discretion of the implementation,
rather than try to retrofit an incompatible change that would
make an infringement be a constraint violation that can't be
checked anyway.
Observing the status quo is better than what, exactly?
The status quo is that the "[static N]" syntax has been in the
language since C99, and programmers and implementations are free
to take advantage of it. I don't recall anyone in this thread
proposing a change to that.
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comvoid Void(void) { Void(); } /* The recursive call of the void */