Compiling net_udp.cpp with clang-3.4 crashes the compiler when parsing
a decltype that refers into the class currently being compiled. Parsing
a decltype that refers to a parent class works. Rearrange the decltype
usage to avoid referencing the current class. This makes the code
harder to read and less flexible, but prevents clang from crashing.
Clang self trace:
1. <eof> parser at end of file
2. similar/main/net_udp.cpp:317:8: instantiating function definition 'operator()'
3. similar/main/net_udp.cpp:317:8: LLVM IR generation of declaration '(anonymous namespace)::sockaddr_dispatch_t<(anonymous namespace)::dxx_recvfrom_t>::operator()'
4. similar/main/net_udp.cpp:317:8: Mangling declaration '(anonymous namespace)::sockaddr_dispatch_t<(anonymous namespace)::dxx_recvfrom_t>::operator()'
[Update: also affects OS X clang v6, as reported by btb: https://github.com/dxx-rebirth/dxx-rebirth/pull/35#issuecomment-73350066]
Previously, the code set itype=IT_POINT, then picked a closest point.
If the closest point was v0 or v1, itype stayed IT_POINT, otherwise it
became IT_EDGE. If itype==IT_POINT, then the function returns
(itype == IT_POINT) ? IT_NONE : itype;
=>
IT_NONE
for (dist <= rad). Otherwise, it returns IT_NONE. Short-circuit this
by returning IT_NONE without computing the distance.
Clang warns for unused static inline functions defined in a source file,
including those defined in a macro in a header, when the macro is
expanded in the source file.
Modifying a by-value temporary does not affect the underlying container,
so modifying it is almost always a bug. Require use of a by-reference
capture when modification is desired.
sed -i -e 's/range_for\s*(\s*\(const\s\+\)\?auto\s\+\([[:alpha:]_]\)/range_for (const auto \2/g'