|
From: | Paul Eggert |
Subject: | Re: emacs-26 9e59de9: Use GCALIGNED properly for GCC |
Date: | Fri, 10 Nov 2017 09:58:03 -0800 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 |
Stefan Monnier wrote:
union gcaligned_foo { struct foo s; int64_t gcaligned; };Are int64_t necessarily aligned on multiples of 8 on 32bit platforms?
No, unfortunately.
IOW, should we rely on alignas? There could be dragons there too, no?FWIW, for the dummy alignment thingy I wouldn't use `char` (I wouldn't be surprised to see errors in compilers when asking to align on multiples of N for objects smaller than N), so maybe #define gc_aligned(typename) \ union { typename s; int64_t alignas (GCALIGNMENT) dummy; };
That does not work either, alas, as C11 says 'alignas (8)' is an error when the natural alignment of the object is less than 8. This is one of the problems that we have encountered in earlier attempts to fix this bug. 'char alignas (8)' avoids this problem.
If we run into a platform where alignas (8) does not work either natively or via Gnulib emulation, the patch I'm working on has a 'verify' check that should result in a build failure. Although I have some ideas for fixing the situation if it arises, they would add some complexity (and would depend on the details of any problematic hosts), and I'd rather avoid this if possible.
[Prev in Thread] | Current Thread | [Next in Thread] |