Exemple where TYPE_ALIGNMENT() fails?

Offsetof is only specified to work for POD types. If a class contains any data members that are not POD, the class itself is not POD. So, if t in your example is a non-POD type, it is not guaranteed to work.

Offsetof is only specified to work for POD types. If a class contains any data members that are not POD, the class itself is not POD. So, if t in your example is a non-POD type, it is not guaranteed to work.

From the C++ standard (18.1/5): The macro offsetof accepts a restricted set of type arguments in this International Standard. Type shall be a POD structure or a POD union. So, if you use offsetof on a non-POD type, the results are undefined.

Well yes but thats not what I asked. For example class foo{ int i; virtual void bar(){ } }; int main(){ std::cout – JustMaximumPower Mar 29 '10 at 14:08 @JustMaximumPower: "Works fine" (or, at least appearing to work fine) is a reasonable outcome for something that is undefined. "Crashes horribly" is another reasonable outcome.

Anything can happen. Whether it appears to work or it causes pernicious bugs in your software is entirely implementation-dependent. It would be unwise to assume that it works for non-POD types.

– James McNellis Mar 29 '10 at 14:30.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions