From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 34885 invoked by alias); 15 Dec 2015 20:03:00 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 34868 invoked by uid 89); 15 Dec 2015 20:02:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qk0-f181.google.com Received: from mail-qk0-f181.google.com (HELO mail-qk0-f181.google.com) (209.85.220.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 15 Dec 2015 20:02:55 +0000 Received: by mail-qk0-f181.google.com with SMTP id p187so31200621qkd.1 for ; Tue, 15 Dec 2015 12:02:55 -0800 (PST) X-Received: by 10.55.74.209 with SMTP id x200mr18117031qka.106.1450209773191; Tue, 15 Dec 2015 12:02:53 -0800 (PST) MIME-Version: 1.0 Received: by 10.55.75.198 with HTTP; Tue, 15 Dec 2015 12:02:23 -0800 (PST) In-Reply-To: <877fkglytf.fsf@oracle.com> References: <565460FB.6070103@redhat.com> <86zixdnlfg.fsf@gmail.com> <566F13D4.9000900@redhat.com> <877fkglytf.fsf@oracle.com> From: Simon Marchi Date: Tue, 15 Dec 2015 20:03:00 -0000 Message-ID: Subject: Re: C++ conversion status update To: "Jose E. Marchesi" Cc: Pedro Alves , Yao Qi , "gdb@sourceware.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-12/txt/msg00014.txt.bz2 On 15 December 2015 at 06:46, Jose E. Marchesi w= rote: > g++ -g -O2 -I. -I../../gdb -I../../gdb/common -I../../gdb/config -DLOCA= LEDIR=3D"\"/usr/local/share/locale\"" -DHAVE_CONFIG_H -I../../gdb/../includ= e/opcode -I../../gdb/../opcodes/.. -I../../gdb/../readline/.. -I../../gdb/.= ./zlib -I../bfd -I../../gdb/../bfd -I../../gdb/../include -I../libdecnumber= -I../../gdb/../libdecnumber -I../../gdb/gnulib/import -Ibuild-gnulib/impo= rt -DTUI=3D1 -I/usr/include/python2.6 -I/usr/include/python2.6 -Wall -Wp= ointer-arith -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-= char-subscripts -Wempty-body -Wno-sign-compare -Wno-write-strings -Wno-narr= owing -Wformat-nonliteral -Werror -c -o sparc64-tdep.o -MT sparc64-tdep.o -= MMD -MP -MF .deps/sparc64-tdep.Tpo ../../gdb/sparc64-tdep.c > cc1plus: warnings being treated as errors > In file included from ../../gdb/target.h:74, > from ../../gdb/exec.h:23, > from ../../gdb/gdbcore.h:29, > from ../../gdb/sparc64-tdep.c:27: > ../../gdb/btrace.h: In function =E2=80=98size_t VEC_btrace_insn_s_embedde= d_size(int)=E2=80=99: > ../../gdb/btrace.h:84: error: invalid access to non-static data member = =E2=80=98VEC_btrace_insn_s::vec=E2=80=99 of NULL object > ../../gdb/btrace.h:84: error: (perhaps the =E2=80=98offsetof=E2=80=99 mac= ro was used incorrectly) > ../../gdb/btrace.h: In function =E2=80=98VEC_btrace_insn_s* VEC_btrace_in= sn_s_alloc(int)=E2=80=99: > ../../gdb/btrace.h:84: error: invalid access to non-static data member = =E2=80=98VEC_btrace_insn_s::vec=E2=80=99 of NULL object > ../../gdb/btrace.h:84: error: (perhaps the =E2=80=98offsetof=E2=80=99 mac= ro was used incorrectly) > ../../gdb/btrace.h: In function =E2=80=98VEC_btrace_insn_s* VEC_btrace_in= sn_s_copy(VEC_btrace_insn_s*)=E2=80=99: > ../../gdb/btrace.h:84: error: invalid access to non-static data member = =E2=80=98VEC_btrace_insn_s::vec=E2=80=99 of NULL object > ../../gdb/btrace.h:84: error: (perhaps the =E2=80=98offsetof=E2=80=99 mac= ro was used incorrectly) > ../../gdb/btrace.h: In function =E2=80=98VEC_btrace_insn_s* VEC_btrace_in= sn_s_merge(VEC_btrace_insn_s*, VEC_btrace_insn_s*)=E2=80=99: > ../../gdb/btrace.h:84: error: invalid access to non-static data member = =E2=80=98VEC_btrace_insn_s::vec=E2=80=99 of NULL object > ../../gdb/btrace.h:84: error: (perhaps the =E2=80=98offsetof=E2=80=99 mac= ro was used incorrectly) > ../../gdb/btrace.h: In function =E2=80=98int VEC_btrace_insn_s_reserve(VE= C_btrace_insn_s**, int, const char*, unsigned int)=E2=80=99: > ../../gdb/btrace.h:84: error: invalid access to non-static data member = =E2=80=98VEC_btrace_insn_s::vec=E2=80=99 of NULL object > ../../gdb/btrace.h:84: error: (perhaps the =E2=80=98offsetof=E2=80=99 mac= ro was used incorrectly) > At global scope: > cc1plus: error: unrecognized command line option "-Wno-narrowing" > make[2]: *** [sparc64-tdep.o] Error 1 > make[2]: Leaving directory `/home/jemarch/couts2/binutils-gdb/build/gdb' > make[1]: *** [all-gdb] Error 2 > make[1]: Leaving directory `/home/jemarch/couts2/binutils-gdb/build' > make: *** [all] Error 2 This can be reproduced with g++ 4.4 on any architecture, i think. This seems to be caused by the interaction of enum_flags and the vector implementation. After preprocessing we have this: __builtin_offsetof (VEC_btrace_insn_s, vec) However, VEC_btrace_insn_s is a non-POD data type, because it ultimately contains an enum_flags object, which is non-POD. VEC_btrace_insn_s btrace_insn_s vec[1]; btrace_insn_flags flags; (enum_flags ) =46rom what I read, using offsetof on a non-POD structure is an undefined behavior, at least in C++98. I don't know if it has changed in later standard versions, but later g++ do not complain. For g++ 4.4, it is possible to silence the warning/error with -Wno-invalid-offsetof, if we know that it still produces good results.