How to correctly read 6.2.5p26?

M

Mark Piffer

6.2.5p26:
"[...] All pointers to structure types shall have the same
representation and alignment requirements as each other. All pointers
to union types shall have the same representation and alignment
requirements as each other. Pointers to other types need not have the
same representation or alignment requirements."

Does the "each other" mean "each other of the same particular type" or
does it refer to all structure types in general? I was of the opinion
that different structure types do not bear the same alignment
requirements, but as non-native english reader I can't really identify
the subtle traces of definitve information in the standard sometimes.

Mark
 
E

Eric Sosman

Mark said:
6.2.5p26:
"[...] All pointers to structure types shall have the same
representation and alignment requirements as each other. All pointers
to union types shall have the same representation and alignment
requirements as each other. Pointers to other types need not have the
same representation or alignment requirements."

Does the "each other" mean "each other of the same particular type" or
does it refer to all structure types in general? I was of the opinion
that different structure types do not bear the same alignment
requirements, but as non-native english reader I can't really identify
the subtle traces of definitve information in the standard sometimes.

It means "all structure types." Different struct types
can have different alignment requirements, but pointers to
all those different struct types have the same alignment
requirement, the same size, and the same representation.

struct a { char c; };
struct b { long double ld[42]; }
/* `struct a' and `struct b' may have different
* alignment requirements.
*/

typedef struct a *pa;
typedef struct b *pb;
/* `pa' and `pb' -- perfectly good data types in
* their own right -- have the same alignment
* requirement.
*/
 

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

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top