PATCH: option to silence warnings about offsetof and non-PODs

Phil Edwards phil@jaj.com
Fri May 16 22:06:00 GMT 2003


On Thu, May 15, 2003 at 01:58:56PM -0700, Matt Austern wrote:
> The warning message is of course correct, and one could even argue that 
> it should be a hard error.  Applying offsetof to a non-POD is 
> undefined.  However, there are also a lot of cases where "POD" is too 
> strict a concept, where the offset of a data member is well defined and 
> the restriction is purely artificial.  (I've raised this issue with the 
> C++ standards committee, and there's general agreement that "POD" was 
> chosen mostly for simplicity rather than because it's essential to the 
> notion of offsets.)  Applying offsetof to simple non-POD types, such as 
> a simple struct with a constructor, is common.  Users who are aware 
> that they're writing nonportable code, and who have deliberately chosen 
> to ignore the warning about it, should be able to do so.

Could perhaps some of this be included in the documentation paragraph?


Phil

-- 
If ye love wealth greater than liberty, the tranquility of servitude greater
than the animating contest for freedom, go home and leave us in peace.  We seek
not your counsel, nor your arms.  Crouch down and lick the hand that feeds you;
and may posterity forget that ye were our countrymen.            - Samuel Adams



More information about the Gcc-patches mailing list