From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7007 invoked by alias); 7 Mar 2015 18:00:58 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 6998 invoked by uid 89); 7 Mar 2015 18:00:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: mtaout20.012.net.il Received: from mtaout20.012.net.il (HELO mtaout20.012.net.il) (80.179.55.166) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 07 Mar 2015 18:00:56 +0000 Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0NKU00F00SJO8P00@a-mtaout20.012.net.il> for gdb-patches@sourceware.org; Sat, 07 Mar 2015 20:00:53 +0200 (IST) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NKU00E52SPGYR60@a-mtaout20.012.net.il>; Sat, 07 Mar 2015 20:00:53 +0200 (IST) Date: Sat, 07 Mar 2015 18:00:00 -0000 From: Eli Zaretskii Subject: Re: [pushed] Fix struct sockaddr/sockaddr_in/sockaddr_un strict aliasing violations In-reply-to: <1425750266-14385-1-git-send-email-palves@redhat.com> To: Pedro Alves Cc: gdb-patches@sourceware.org Reply-to: Eli Zaretskii Message-id: <83r3t0lmb9.fsf@gnu.org> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-transfer-encoding: 8BIT References: <1425750266-14385-1-git-send-email-palves@redhat.com> X-IsSubscribed: yes X-SW-Source: 2015-03/txt/msg00195.txt.bz2 > From: Pedro Alves > Date: Sat, 7 Mar 2015 17:44:26 +0000 > > Building gdbserver in C++ mode shows: > > gdb/gdbserver/tracepoint.c: In function ‘void* gdb_agent_helper_thread(void*)’: > gdb/gdbserver/tracepoint.c:7190:47: error: cannot convert ‘sockaddr_un*’ to ‘sockaddr*’ for argument ‘2’ to ‘int accept(int, sockaddr*, socklen_t*)’ > fd = accept (listen_fd, &sockaddr, &tmp); > > A few places in the tree already have an explicit cast to struct > sockaddr *, but that's a strict aliasing violation. Instead of > propagating invalid code, fix this by using a union instead. Yuck! Isn't there a better way? Why do we have the original problem to begin with, i.e. where did the incompatible data type come from? (Does it even make sense to work around C++ restrictions while converting code to C++?) Thanks.