This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13275] [3.4 regression] Implementation of offsetof macro
- From: "giovannibajo at libero dot it" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 7 Dec 2003 23:03:09 -0000
- Subject: [Bug c++/13275] [3.4 regression] Implementation of offsetof macro
- References: <20031203003343.13275.jbrandmeyer@earthlink.net>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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