Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
events: Remove strict-aliasing warning
Several opaque buffers are used to to wrap c++ classes to pass to the c layer. The reinterpret cast to c++ classes is fine as long as the underlying buffer is not interpreted as different incompatible types, or else the behaviour is undefined. In the equeue_tick_init function, placement new is used to initialize the buffers. However, this interprets the buffer as a simple array of bytes, not the actual class type. Later the buffer is casted to the class type. From the point of view of the compiler, these two types are incompatible, and the compiler is free to reorder the operations under the assumption that they can't affect each other. Reinterpet casting the buffer to a class pointer before using placement new insures that the buffer is only interpreted as a single type. Or simple using the return value from placement new will handle the aliasing appropriately.
- Loading branch information