Pointer arithmetic involving NULL pointers

  • Thread starter Christopher Benson-Manica
  • Start date
J

Jason Curl

Michael said:
While we're pointing out errors here, I'd like to note that a pointer
can contain something other than a simple address; and there is at
least one implementation (AS/400 ILE C) which I believe is conforming
and which does so. (ILE C pointers contain some kind of reference to
a "memory space" and an offset into that space, and possibly other
information; some of this can be seen by displaying the value of a
valid non-null pointer with the "%p" printf specifier.)

So besides not assuming that null pointers have the value all-bits-
zero, you shouldn't assume that non-null pointers have just a simple
address.
Out of curiosity - is this something like "smart pointers", where a
compiler can have an implementation of a pointer as some kind of
datastructure that can be used for "secure" programming (avoiding buffer
overflows)?

Does anyone know of any compilers for IA32 (Win / Linux) that might be
free that implements more complex pointers?

Jason.
 
M

Michael Wojcik

Out of curiosity - is this something like "smart pointers", where a
compiler can have an implementation of a pointer as some kind of
datastructure that can be used for "secure" programming (avoiding buffer
overflows)?

I generally see the phrase "smart pointers" in reference to C++,
where operator overloading lets the programmer do things behind the
scenes when the pointer operators are used. Personally, I'd avoid
using "smart pointers" for a case like this, since it's not a
particularly descriptive term.

The implementations I mentioned do indeed catch a variety of pointer
errors. A fancy pointer representation isn't actually required for
that purpose (an implementation might, for example, track valid
pointers internally - the information doesn't need to be in the
pointer representation itself).
Does anyone know of any compilers for IA32 (Win / Linux) that might be
free that implements more complex pointers?

I don't, and it's unlikely that such an implementation exists for
either Windows or Linux on IA32, since it would be incompatible with
the system interfaces for those OSes. An implementation that used
metadata not stored in the pointer to validate accesses is more
plausible, but I don't know of one.

There are, of course, various simulation and instrumentation packages
for those platforms which can detect some types of pointer errors
without changing the pointer representation. The ones I've worked
with are not free (unless you include Electric Fence in this
category).
 
D

Dan Pop

In said:
Out of curiosity - is this something like "smart pointers", where a
compiler can have an implementation of a pointer as some kind of
datastructure that can be used for "secure" programming (avoiding buffer
overflows)?

Does anyone know of any compilers for IA32 (Win / Linux) that might be
free that implements more complex pointers?

Have a look at http://sourceforge.net/projects/boundschecking/

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top