Sujet : Re: unaligned load/store
De : jgd (at) *nospam* cix.co.uk (John Dallman)
Groupes : comp.archDate : 22. Dec 2024, 12:42:27
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <memo.20241222114228.20984L@jgd.cix.co.uk>
References : 1
In article <
vk8o2c$in5m$1@dont-email.me>,
tkoenig@netcologne.de (Thomas
Koenig) wrote:
These days, the competence of many programmers can be called into
question :-)
ABIs, however, generally require natural alignment for types, so
the point is somewhat moot, at least where user code is concerned.
Consider
Decades ago, there seems to have been a fashion among Windows application
programmers for using somewhat tighter packing. For reasons that I still
don't really understand, Microsoft's x86 C/C++ compiler provides an
option for setting the largest alignment allowed. If you set it to two
bytes, shorts still get natural alignment, but everything larger is
aligned to two-byte boundaries.
After we'd explained to the third customer that this would not work with
our libraries, it got a paragraph in the documentation, explicitly saying
that it you used it, the libraries would crash. No attempts to do this
have reached second-line support since then. Sometimes, a totally
unvarnished warning is the right thing to use.
John