Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c++ Subject: Re: Performance of unaligned memory-accesses Date: Sun, 11 Aug 2019 13:11:26 -0700 Organization: None to speak of Lines: 23 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="cb4b2dc0baf4fefc9628bc1b5f7f50df"; logging-data="17775"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+8lka00lAyEY9OLSGY9Jhg" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:y5MwpgDY3sGlwsYJMf0M+J5Ou+w= sha1:Ze3zg1PSrwB/1EkHGKwmJAMDKbQ= Xref: csiph.com comp.lang.c++:67570 David Brown writes: [...] > With that alignment decision made, the C standard explicitly says that > conversions to pointers that result in them being unaligned, are > undefined behaviour - as is dereferencing unaligned pointers. A C > implementation can, of course, give a definition for how it treats > unaligned pointers - but if it does not, then you have to assume that > they are simply not allowed. (Did you mean to say "C++ standard"?) You weaken your argument by using phrases like "not allowed". There are very few things that are not allowed by the standard. For undefined behavior, the compiler is not obligated to diagnose the problem, and the run-time behavior *can* be exactly what someone might naively expect. I suggest sticking to the terms defined by the standard itself. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */