Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c++
Subject: Re: Performance of unaligned memory-accesses
Date: Wed, 14 Aug 2019 09:27:47 -0700
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <86mugb7lvg.fsf@mailhub.linuxsc.com>
References: <_ic4F.727$t92.96@fx25.am4> <7yd4F.2$CO2.0@fx30.am4>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="f86338710750d7af41889a1532e7291c"; logging-data="23014"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX193VdHrN0qIY2xm0EaC/PJWSXzUDIEWuAE="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:JiF8fUVmjQS0o9kKTXFRty8B6pE= sha1:uXieoXoMT87Uh4hUQMhpn3Ea19E=
Xref: csiph.com comp.lang.c++:67654
Bonita Montero writes:
>> Again, I commented assertion that unaligned access causes undefined
>> behavior. And I don't care what 0x3 means.
>
> As I said that's not undefined behaviour because the compiler would
> be unable to generate the code as expected but because the CPU might
> fail / trap an unaligned access at runtime and the OS might emulate
> tzhe unaligned access or not. So it depends on the platform you
> target.
If a given operation has undefined behavior, it doesn't stop
having undefined behavior just because it happens to do what
you want it to.