Is the following code well defined?
struct S { int x; };
alignas(alignof(S)) char c_arr[sizeof(S)];
S *s_ptr = (S*)c_arr;
s_ptr->x = 5; // UB or not UB?
Note: S is purposfully defined as a Trivial Type.
Would the situation change if we made the type none trivial by adding a constructor that just sets X to some arbitrary value without calling it through placement new?
This question is different from this question because it does not use malloc and does ask also about none trivial types.