tests: Fix strict aliasing of sockaddr structures
authorPhilip Withnall <philip.withnall@collabora.co.uk>
Wed, 15 Jan 2014 08:51:28 +0000 (08:51 +0000)
committerOlivier Crête <olivier.crete@collabora.com>
Fri, 31 Jan 2014 06:48:57 +0000 (01:48 -0500)
commitfd6aa7b2617db328eee0ae42068d3a558e1a4f32
tree320c6dc6df19ee97f9aad414408d49210a5e97b5
parent344b7b67ec7f7dfd10bed9d397db57d0940f7c79
tests: Fix strict aliasing of sockaddr structures

Casting from one struct sockaddr type to another breaks C’s strict
aliasing rules (variables of different types cannot alias). Fix this
cleanly by using unions of struct sockaddrs to convert between the
types (i.e. type-punning).

I wish sockaddr didn’t have to be this painful.

See:
http://gcc.gnu.org/onlinedocs/gcc-4.4.1/gcc/Optimize-Options.html#Type_002dpunning
tests/test-address.c
tests/test-new-dribble.c