Ternary Conditional Fun Macros for Any Type

N

Nick Keighley

On Aug 3, 8:35 am, Nick Keighley <[email protected]>

or rather doesn't point to an object
Which part of the ANSI C Standard states this?  I don't see it.


It's handy to have. :)



Erm, the result of the 'TT' macro isn't a null pointer constant.  

but it compares equal to a null pointer constant. Actually 0 (zero)
*is* a null pointer constant! But, whatever, your pointer doesn't
point to a valid object
It's
a null pointer.  Also, a null pointer of type 'type *' points to an
object type if 'type' is an object type, doesn't it?  
no


The null pointer
compares unequal to any pointer to an object, but does that mean it
doesn't point to an object type?

er, yes...

Ok. :)




Nope.  The little letters were subjects, the big letters were
predicates; properties/attributes to be either true or false,
effectively providing a means of classification.  Sorry to confuse.

or just drop the constant bit
Ah, but 'TT' doesn't yield 'NPC'.



Aha.  I guess I'm confused by the definition of casting an integer to
a pointer with an implementation-defined result.  This brings flatness
to my mind.

it only says you convert back and forth it doesn't say there are no
holes in the memory map


-ish. I'm assuming it wraps so the successor to the largest addres is
the smallest. Probably true on a lot of systems but not all. It also
assumes there aren't disjoint memory spaces which would be odd but not
illegal. C sort of seems to imply objects and functions are in
different incompatible spaces. Or at least are allowed to be.

1. there is a lowest address Z
2. there is a highest address H
3. every address except H has a successor
4. by repeatedly taking successors starting from Z every address can
be reached
As above.

which above?

I'm pretty sure we can show the the standard doesn't require flatness
(you can't reach one array from another). And I think you can run a
non-flat model on top of a flat model. Though you might need very
large addresses in the flat model.

Well yes, the code does need to pretend we have an array large enough
to stretch from the null pointer (which is assumed to represent
address 0) through our scratch space.  The original post mentions this
pretense.
the fact that C can be implemented on flat memories is a pointer that
C is not incompatible with a flat model

Ok. :)
well no actually. Certain arithmatic on some pointers may result in
undefined [behaviour] adding anything non-zero to a null pointer is undefined.

Could you possibly share your thoughts on what pinpoints the
boundaries for objects, according to some C Standard?  The pointer
arithmetic is well-defined based on some notion of "number of
elements" and "array object," but how are these precisely defined?

<snip>

not sure exactly. But from the Definitions section "objects are
composed of contiguous sequences of one or more bytes"
 

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
474,085
Messages
2,570,597
Members
47,218
Latest member
GracieDebo

Latest Threads

Top