bug-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

g++ offsetof() bug?


From: Otto Lind
Subject: g++ offsetof() bug?
Date: 30 Oct 2003 09:38:37 GMT

The following code:

#include <stddef.h>
struct Foo
{
        Foo& operator=(const Foo& offset) { }
};
struct Bar
{
        Foo next;
};
int main()
{
        return offsetof(Bar, next);
}

Results in:

% /opt/gnu/bin/gcc --version
gcc (GCC) 3.3.2
...
% /opt/gnu/bin/gcc foo.cpp   
foo.cpp: In function `int main()':
foo.cpp:18: warning: invalid access to non-static data member `Bar::next' of 
   NULL object
foo.cpp:18: warning: (perhaps the `offsetof' macro was used incorrectly)

Does defining an assignment operator really make struct Foo a non-POD
data type?

Otto




reply via email to

[Prev in Thread] Current Thread [Next in Thread]