Path: csiph.com!fu-berlin.de!uni-berlin.de!news.dfncis.de!not-for-mail From: =?UTF-8?Q?Hans-Bernhard_Br=C3=B6ker?= Newsgroups: comp.std.c Subject: Re: May a string span multiple, independent objects? Date: Wed, 3 Jul 2024 17:23:24 +0200 Lines: 18 Message-ID: References: <20240703141500$00ed@vinc17.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.dfncis.de kGL5hQuKZytRuuOAA8CWqQe3KIjXb7Y0wycobprwKQ0DKPkUuTUTrVE0Y/ Cancel-Lock: sha1:306BY8pr1nA6ZGkbqA3hyApYi58= sha256:LBr5ihNgxgj5PwtHP2VxVvrEryYW/fKjy3jQwyJ/S18= User-Agent: Mozilla Thunderbird Content-Language: de-DE, en-US In-Reply-To: <20240703141500$00ed@vinc17.org> Xref: csiph.com comp.std.c:6647 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.