[Bug c++/13275] [3.4 regression] Implementation of offsetof macro

giovannibajo at libero dot it gcc-bugzilla@gcc.gnu.org
Sun Dec 7 23:03:00 GMT 2003


------- Additional Comments From giovannibajo at libero dot it  2003-12-07 23:03 -------
Also consider this case:

----------------------------------------------
template <bool> struct StaticAssert;
template <> struct StaticAssert<true> {};

struct MyPOD
{
  int a; int b; int c; 
};

StaticAssert<(offsetof(MyPOD, a) == 0)> s;
----------------------------------------------

The current implementation is broken because it uses pointer casts and stuff 
which are not allowed in constant-expressions for template arguments. I have a 
patch in progress which makes the compiler strictier about this and reject this 
code. BTW it comes from Boost.Python, and EDG agrees that's broken.

We need a builtin.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13275



More information about the Gcc-bugs mailing list