Paul Eggert schrieb am Mi., 17. Mai 2017 um 22:38 Uhr: > On 05/15/2017 02:04 AM, Philipp Stephani wrote: > > - Maybe add verify(INT_MAX >= TYPE_MAXIMUM(in_port_t)) and > > verify(TYPE_MINIMUM(in_port_t) == 0) to make sure that we can use int > > for the port? > > The code has been changed so that the port number is no longer stored in > an int so this remark is obsolete now. However, if this issue crops up > later I don't think we need to worry about it for IPv4 and IPv6 ports, > since they're always in the range 0..65535. Emacs already assumes that > 'int' is at least 32 bits wide, as per POSIX. > Yes, these static assertions are more for documenting the assumptions that the code makes in a way that actually checks the assumptions. > > > - Should there be a guard against the alias violation, e.g. by > > declaring sa and sa1 with __attribute__((may_alias))? Otherwise it's > > UB and the compiler might elide the switch entirely. > > Yes, that is easy enough to do and would avoid some unlikely but > hard-to-catch bugs. I installed the attached. Most likely other parts of > Emacs should use may_alias too; do you happen to have any tool in your > toolbox that would find them systematically? > > A type-based aliasing sanitizer is currently being added to Clang. Once that is landed I'll run it over the Emacs codebase.