This is the mail archive of the gcc-bugs@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]

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


------- 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


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