A malloc question

D

Dietmar Schindler

Eric said:
..., but I agree that all struct pointers have the same
representation (because the Standard says so, in 6.2.5/26).

However, a shared representation does not imply a common
universe of values! The value of a representation depends on
the type of the expression that accesses it. A particular
representation R (a "bit pattern," if that's more down-to-earth)
may be a value for a `struct S*' but a trap representation for a
`struct T*'. A pointer representation that doesn't satisfy the
alignment requirements of the pointed-to type is not a value
(in the sense that C uses the term) but a trap representation.

The statement "All pointers to structure types shall have the same
representation ... as each other" in 6.2.5/26 leaves no room for
restriction to certain values.
Also, I see no wording in the standard which said that a misaligned
pointer would be a trap representation.
 

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

Similar Threads

A malloc question, part 2 25
Alternative to Malloc in C 0
malloc 40
Naive Custom Malloc Implementation 8
array-size/malloc limit and strlen() failure 26
malloc 33
malloc() and implicit cast 49
Malloc question 9

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,230
Latest member
LifeBoostCBD

Latest Threads

Top