Article View: comp.std.c++
Article #657Re: Zero-length structures and pointer comparisons
From: Markku Sakkinen
Date: Wed, 11 Nov 1992 09:44
Date: Wed, 11 Nov 1992 09:44
39 lines
1822 bytes
1822 bytes
In article <1992Nov10.185247.14128@sophists.com> lewis@sophists.com (Lewis G. Pringle) writes:
>In article <1992Nov4.080805.13496@jyu.fi> sakkinen@jyu.fi (Markku Sakkinen) writes:
>...
>>I would first like to return to a much more important, related problem,
>>which somebody brought up here rather recently.
>> ...
I am still waiting for an answer to that question.
Nobody got a clue?
>I'd like to ask a related question.
>
>Given code like:
>
>char* start = new char [10];
>char* end = start+10;
>char* p = start;
> ...
>p = start;
>p--;
>assert (! ((p >= start) && (p <= end))); // ???????
>
>Is the last assertion portable? ARM/ANSI-C References?
Certainly not portable. The ARM (o. 72 - 73) says that 'p--' above
is undefined; I would suppose that an implementation is allowed
even to abort the programme at that point. Or, 'p > start' and
'p < start' might both yield true, and 'p >= start' and 'p <= start'
both false.
----------------------------------------------------------------------
Markku Sakkinen (sakkinen@jytko.jyu.fi)
SAKKINEN@FINJYU.bitnet (alternative network address)
Department of Computer Science and Information Systems
University of Jyvaskyla (a's with umlauts)
PL 35
SF-40351 Jyvaskyla (umlauts again)
Finland
----------------------------------------------------------------------
Technical Details
Message-ID:
<1992Nov11.094404.7382@jyu.fi>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!news.funet.fi!network.jyu.fi!sakkinenReferences:
<1992Oct30.003946.10484@microsoft.com> <1992Nov4.080805.13496@jyu.fi> <1992Nov10.185247.14128@sophists.com>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++ Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!news.funet.fi!network.jyu.fi!sakkinen From: sakkinen@jyu.fi (Markku Sakkinen) Subject: Re: Zero-length structures and pointer comparisons Message-ID: <1992Nov11.094404.7382@jyu.fi> Organization: University of Jyvaskyla, Finland References: <1992Oct30.003946.10484@microsoft.com> <1992Nov4.080805.13496@jyu.fi> <1992Nov10.185247.14128@sophists.com> Date: Wed, 11 Nov 1992 09:44:04 GMT Lines: 39