Open
Description
union semun
, in unix/bsd/apple/mod.rs, has three fields. On LP64, these fields will have unequal sizes. But its PartialEq and Hash implementations only check the smallest field. So the following code should fail (untested, because I don't have access to a Mac):
use libc::semun;
#[test]
fn semun_eq() {
let x = semun{ val: 0x44556677 };
let y = semun{ array: 0x0011223344556677 };
assert!(x != y);
}
A similar situation holds on Linux for __c_anonymous_ptrace_syscall_info_data
. That union has three members of different sizes, and its PartialEq
implementation will return turn as long as any pair of fields compare equal. Effectively, that means it's only comparing the smallest field.
There are other unions in libc, but I haven't audited them all.