Commit 9d0045443d51fc26ad1c2bb1e63e78519c7654e4

safocl 2025-09-16T00:16:30

Fix invalid reinterpret_cast (#5558) * Fix invalid reinterpret_cast reinterpret_cast from non-atomic object to atomic object is not valid. https://eel.is/c++draft/atomics.types.generic#general-3 >[Note 2: The representation of an atomic specialization >need not have the same size and alignment requirement as >its corresponding argument type. — end note] https://eel.is/c++draft/basic.compound#5 >5 Two objects a and b are pointer-interconvertible if >(5.1) they are the same object, or >(5.2) one is a union object and the other is a non-static >data member of that object ([class.union]), or >(5.3) one is a standard-layout class object and the other >is the first non-static data member of that object or any >base class subobject of that object ([class.mem]), or >(5.4) there exists an object c such that a and c are >pointer-interconvertible, and c and b are pointer-interconvertible. >If two objects are pointer-interconvertible, then they have >the same address, and it is possible to obtain a pointer >to one from a pointer to the other via a reinterpret_cast >([expr.reinterpret.cast]). objects of types `int` and `std::atomic<int>` are not pointer-interconvertible (an object of type `int` is not first non-static data member of `std::atomic<int>`) https://eel.is/c++draft/basic.lval#11 >11 An object of dynamic type T-obj is type-accessible through >a glvalue of type T-ref if T-ref is similar ([conv.qual]) to: >(11.1) T-obj, >(11.2) a type that is the signed or unsigned type corresponding >to T-obj, or >(11.3) a char, unsigned char, or std::byte type. >If a program attempts to access ([defns.access]) the stored >value of an object through a glvalue through which it is not >type-accessible, the behavior is undefined The original code resulted in undefined behavior. * revert code formatting * fix const qualifier in type for atomic operation. * implement copy and move ctors (assignment-operators) and swap functions. * swap-functions replaced as frendly members, common header includes returned. * add HB_ prefix to defined macro. * some formatting.