search for: misaligned_a_b

Displaying 3 results from an estimated 3 matches for "misaligned_a_b".

2016 Jan 15
2
[cfe-dev] RFC: Enforcing pointer type alignment in Clang
...and thus, the value of "p" is misaligned for its type. And so, you can no longer dereference it nor access members. That seems all fine and sensible to me. If you need to give a name "p" to the value, you can still do like this: typedef struct A::B __attribute__((aligned(1))) misaligned_A_B; misaligned_A_B *p = &a.b; int x = p->n; AFAICT, this all works today, as well. Now, of course, the "aligned" attribute being able to reduce the alignment of a type -- but only when used in a typedef (!!!) -- is a non-standard GCC extension which is not even properly document...
2016 Jan 18
3
[cfe-dev] RFC: Enforcing pointer type alignment in Clang
Hi John, On 15 Jan 2016, at 08:14, John McCall via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > The question at hand is whether we should require the user to write this: > misaligned_A_B *p = &a.b; > instead of, say: > A::B *p = &a.b; > int x = *(misaligned_int*) &p->n; > because we want to reserve the right to invoke undefined behavior and propagate our “knowledge" that p is 4-byte-aligned to “improve” the 1-byte-aligned access on the next line....
2016 Jan 15
3
[cfe-dev] RFC: Enforcing pointer type alignment in Clang
> On Jan 14, 2016, at 4:49 PM, Richard Smith <richard at metafoo.co.uk> wrote: > On Thu, Jan 14, 2016 at 12:56 PM, John McCall via cfe-dev <cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>> wrote: > C 6.3.2.3p7 (N1548) says: > A pointer to an object type may be converted to a pointer to a > different object type. If the resulting pointer is not