On Wed, Jun 12, 2013 at 10:23 AM, Martin Jambor <[email protected]> wrote:
> Hi everyone, but especially Diego :-)
>
> it seems to me that our new C++ vectors have some problems holding
> derived classes. For example, when try to compile the following
I think the answer is simple. vec supports POD only, once you have
inherents, it becomes non-POD in C++98.
Thanks,
Andrew Pinski
>
> struct zzzA
> {
> int kind;
> };
>
> struct zzzB : public zzzA
> {
> int some, data, here;
> };
>
> struct container
> {
> vec <zzzB> my_vec;
> };
> static struct container my_cnt;
>
> /* and then somewhere later do */
> my_cnt.my_vec.create (8);
>
> I get the following warnings:
>
> In file included from /home/mjambor/gcc/small/src/gcc/tree.h:27:0,
> from /home/mjambor/gcc/small/src/gcc/ipa-cp.c:106:
> /home/mjambor/gcc/small/src/gcc/vec.h: In instantiation of ‘static size_t
> vec<T, A, vl_embed>::embedded_size(unsigned int) [with T = zzzB; A = va_heap;
> size_t = long unsigned int]’:
> /home/mjambor/gcc/small/src/gcc/vec.h:298:64: required from ‘static void
> va_heap::reserve(vec<T, va_heap, vl_embed>*&, unsigned int, bool) [with T =
> zzzB]’
> /home/mjambor/gcc/small/src/gcc/vec.h:1468:5: required from ‘bool vec<T, A,
> vl_ptr>::reserve(unsigned int, bool) [with T = zzzB; A = va_heap]’
> /home/mjambor/gcc/small/src/gcc/vec.h:1482:45: required from ‘bool vec<T,
> A, vl_ptr>::reserve_exact(unsigned int) [with T = zzzB; A = va_heap]’
> /home/mjambor/gcc/small/src/gcc/vec.h:1497:5: required from ‘void vec<T, A,
> vl_ptr>::create(unsigned int) [with T = zzzB; A = va_heap]’
> /home/mjambor/gcc/small/src/gcc/ipa-cp.c:3608:26: required from here
> /home/mjambor/gcc/small/src/gcc/vec.h:1091:63: warning: invalid access to
> non-static data member ‘vec<zzzB, va_heap, vl_embed>::vecdata_’ of NULL
> object [-Winvalid-offsetof]
> /home/mjambor/gcc/small/src/gcc/vec.h:1091:63: warning: (perhaps the
> ‘offsetof’ macro was used incorrectly) [-Winvalid-offsetof]
> rm -rf libbackend.a
>
> Note that in the warning messages, the template parameters of vec
> change from (IMHO correct) vec<T, A, vl_ptr> to (IMHO wrong)
> vec<T, va_heap, vl_embed>.
>
> When I remove the ": public zzzA" part the earnings disappear. Thus,
> it seems there is an error somewhere... or am I doing something wrong?
>
> Thanks,
>
> Martin