Re: May a string span multiple, independent objects?

Liste des GroupesRevenir à cs c 
Sujet : Re: May a string span multiple, independent objects?
De : jameskuyper (at) *nospam* alumni.caltech.edu (James Kuyper)
Groupes : comp.std.c
Date : 03. Jul 2024, 17:11:25
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v63t7d$28fl8$4@dont-email.me>
References : 1 2
User-Agent : Mozilla Thunderbird
On 7/3/24 11:23, Hans-Bernhard Bröker wrote:
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")

Comparison of valid pointers that point at distinct objects has
well-defined behavior. Such operations would be pretty useless if that
weren't the case, since they only compare the locations of those objects
- if they were allowed only for objects that are  not distinct, the
locations would necessarily be the same, so, ==, <= and >= would always
return true, and !=, <, and > would always return false.

Furthermore, comparison for equality (as opposed to comparison for
relative order) is permitted even for objects that aren't sub-objects of
the same larger object. The problems with such code involves
incrementing and dereferencing such pointers, not comparing them.

Date Sujet#  Auteur
3 Jul 24 * May a string span multiple, independent objects?13Vincent Lefevre
3 Jul 24 +* Re: May a string span multiple, independent objects?4Hans-Bernhard Bröker
3 Jul 24 i+- Re: May a string span multiple, independent objects?1Vincent Lefevre
3 Jul 24 i+- Re: May a string span multiple, independent objects?1James Kuyper
8 Aug 24 i`- Re: May a string span multiple, independent objects?1Tim Rentsch
3 Jul 24 +* Re: May a string span multiple, independent objects?7James Kuyper
3 Jul 24 i`* Re: May a string span multiple, independent objects?6Ben Bacarisse
3 Jul 24 i +- Re: May a string span multiple, independent objects?1James Kuyper
4 Jul 24 i `* Re: May a string span multiple, independent objects?4Vincent Lefevre
5 Jul 24 i  +- Re: May a string span multiple, independent objects?1Ben Bacarisse
5 Jul 24 i  +- Re: May a string span multiple, independent objects?1James Kuyper
8 Aug 24 i  `- Re: May a string span multiple, independent objects?1Tim Rentsch
5 Jul 24 `- Re: May a string span multiple, independent objects?1Kaz Kylheku

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal