This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [13278] sizeof and allignment on 32bit target


John S. Yates, Jr. wrote:

offsetof(struct foo, last_member) + sizeof a[0].last_member;

Sure. If you know the exact declaration of a type and are willing to abandon any pretense to abstraction or maintainability.

You're already in that territory, if you need access to that number.

My point was that a compiler synthesizing an assignment
operation for a POD-type probably uses a number other
than sizeof(<type>) for the number of bytes to be copied.

Your construction only reaffirms that point.

No, a compiler is explicitly allowed to use sizeof(type).


Overwriting padding bytes is guaranteed to be safe.

Can you point to chapter and verse where either a C or a C++ standard insists that an implementation provide padding beyond the declared members of a free-standing struct or union?

C99, 6.2.6.1; a footnote says exactly that, even.



Segher




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]