You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
which is effectively a cast between &[T; 2] and &(T, T) and contains unspecified behavior since the layout of tuples (exept the unit ()) is not defined.
I noticed a few more impls which suffer from the same bug:
AsRef<(S..)>, AsMut<(S..)>, From<&(S..)> and From<&mut (S..)>
For each vector, point and the quaternion.
A possible solution I came up with is to check that the layout of the Vectors and Tuples match either at compile- or runtime.
This would mean that code that currently works stays the same, and if the layout of tuples happens to be different (possible field reordering) either a compile-error or a panic occurs.
The conversion between a vector and a tuple is defined as follows:
https://docs.rs/cgmath/0.18.0/src/cgmath/macros.rs.html#226-238
which is effectively a cast between
&[T; 2]
and&(T, T)
and contains unspecified behavior since the layout of tuples (exept the unit()
) is not defined.https://doc.rust-lang.org/reference/type-layout.html#tuple-layout
The text was updated successfully, but these errors were encountered: