Bugzilla – Bug 779
Union casting in util/ub_event.c and util/ub_event_pluggable.c is non-portable
Last modified: 2016-07-20 14:11:21 CEST
When compiling unbound 1.5.9 with HP-UX 11.31 using HP's ANSI C compiler, the union casting used in util/ub_event.c and util/ub_event_pluggable.c causes compilation failures because that compiler doesn't support such casting.
For example, util/ub_event.c defines four macros (AS_EVENT_BASE(x), AS_UB_EVENT_BASE(x), AS_EVENT(x) and AS_UB_EVENT(x)) that cast a union type that isn't supported by HP's ANSI C and produce this compiler error:
cc: "util/ub_event.c", line 264: error 1527: Incompatible types in cast: Must cast from scalar to scalar or to void type.
[19 other identical errors later in the file]
The similar macros (AS_MY_EVENT_BASE(x) and AS_MY_EVENT(x)) in util/ub_event_pluggable.c also produced the same sort of error. I'm not sure if union casting is a gcc-only feature, but I suspect other non-gcc compilers may have a similar issue.
I did not know it was nonportable. It was introduced because of gcc type-punned pointer warnings I think.
Fixed in the code repository. Thank you for the report.
Best regards, Wouter
*** Bug 799 has been marked as a duplicate of this bug. ***