Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [pushed] Fix struct sockaddr/sockaddr_in/sockaddr_un strict aliasing violations
Date: Sat, 07 Mar 2015 18:00:00 -0000	[thread overview]
Message-ID: <83r3t0lmb9.fsf@gnu.org> (raw)
In-Reply-To: <1425750266-14385-1-git-send-email-palves@redhat.com>

> From: Pedro Alves <palves@redhat.com>
> 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.


  reply	other threads:[~2015-03-07 18:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-07 17:44 Pedro Alves
2015-03-07 18:00 ` Eli Zaretskii [this message]
2015-03-07 18:20   ` Pedro Alves
2015-03-07 18:53     ` Eli Zaretskii
2015-03-09 10:45       ` Pedro Alves
2015-03-09 11:10         ` Pedro Alves
2015-03-09 11:38           ` Pedro Alves
2015-03-09 16:04             ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83r3t0lmb9.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox