Sujet : Re: May a string span multiple, independent objects?
De : HBBroeker (at) *nospam* gmail.com (Hans-Bernhard Bröker)
Groupes : comp.std.cDate : 03. Jul 2024, 16:23:24
Autres entêtes
Message-ID : <lel8ndF7f8iU1@mid.dfncis.de>
References : 1
User-Agent : Mozilla Thunderbird
Am 03.07.2024 um 16:31 schrieb Vincent Lefevre:
ISO C17 (and C23 draft) 7.1.1 defines a string as follows: "A string
is a contiguous sequence of characters terminated by and including
the first null character."
But may a string span multiple, independent objects that happens
to be contiguous in memory?
For instance, is the following program valid and what does the ISO C
standard say about that?
Comparing pointers pointing at distinct objects is already invalid (for some interpretation of "invalid"), so: no. Yes, that means the implementation of a function like memmove() cannot be fully portable C.
A program whose correctness relies on things "happening to be" just like so cannot possibly be entirely valid.