From: "Mr. Peter Ivanyi" <peteri@carme.sect.mce.hw.ac.uk>
Cc: "guile-devel@gnu.org" <guile-devel@gnu.org>
Subject: Re: SCM_PTR_LE ?
Date: Thu, 01 Aug 2002 18:09:59 +0100 [thread overview]
Message-ID: <3D496B67.D902AD62@carme.sect.mce.hw.ac.uk> (raw)
In-Reply-To: lj4ree5y7l.fsf@burns.dt.e-technik.uni-dortmund.de
Marius Vollmer wrote:
> What is that definition? I think ANSI C only defines the outcome of
> comparisons for pointers that point into the same object, i.e., the
> same array or a single block returned from malloc. A consequence
> would be that you can not reliably test whether a pointer does point
> into some object, since the results are not defined when it points
> outside. For example, is the following guaranteed to print "sane"?
>
> char block1[100];
> char block2[100];
>
> char *ptr = block1 + 50;
>
> if (ptr >= block2 && ptr < block2+100)
> printf ("sane\n");
> else
> printf ("insane\n");
>
> I don't know.
Well, some of the memory checker programs would definitely signal an error
for the above code. As I remember, ANSI defines, that if a pointer goes
out of its range, then it becomes undefined. This have the unfortunate
consequence that
block2+2000-1990
is not valid, you have to calculate the offset first, than use it with the
pointer. On the positive side though, I have never seen, heard any compiler
which takes this as a problem, only memory checker.
Hope it helps a little bit.
Peter Ivanyi
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
next prev parent reply other threads:[~2002-08-01 17:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-27 18:50 SCM_PTR_LE ? Han-Wen
2002-07-30 17:00 ` Marius Vollmer
2002-07-30 22:24 ` Han-Wen
2002-08-01 16:40 ` Marius Vollmer
2002-08-01 17:09 ` Mr. Peter Ivanyi [this message]
2002-08-01 17:15 ` Lynn Winebarger
2002-08-01 20:08 ` Marius Vollmer
2002-08-01 17:16 ` Han-Wen Nienhuys
2002-08-01 17:24 ` Han-Wen Nienhuys
2002-08-01 20:09 ` Marius Vollmer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3D496B67.D902AD62@carme.sect.mce.hw.ac.uk \
--to=peteri@carme.sect.mce.hw.ac.uk \
--cc=guile-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).