[cfe-commits] [QUESTION] - funky declaration
Douglas Gregor
dgregor at apple.com
Mon Jul 26 16:17:26 PDT 2010
On Jul 26, 2010, at 4:15 PM, John Thompson wrote:
> And also this one (bug 7109):
>
> class test
> {
> public:
> test();
> int member;
> };
>
> class testStruct
> {
> public:
> testStruct();
> test t;
> };
>
> int i = __builtin_offsetof (testStruct, t);
>
> >clang -cc1 offsetof1.cpp
> offsetof1.cpp:15:9: warning: offset of on non-POD type 'testStruct'
> int i = __builtin_offsetof (testStruct, t);
> ^ ~
> 1 warning generated.
> ---
> Or is it because neither class is strictly POD?
>
> This still has the warning:
>
> struct test
> {
> public:
> test();
> int member;
> };
>
> struct testStruct
> {
> test t;
> };
>
> int i = __builtin_offsetof (testStruct, t);
>
> But this does not:
>
> struct test
> {
> int member;
> };
>
> struct testStruct
> {
> test t;
> };
>
> int i = __builtin_offsetof (testStruct, t);
Clang appears to be doing the right thing in all cases. offsetof isn't defined on non-POD types.
- Doug
More information about the cfe-commits
mailing list