This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [pushed] Fix struct sockaddr/sockaddr_in/sockaddr_un strict aliasing violations


> 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]