[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: (ITS#8819) LMDB seg fault with MDB_DUPSORT on -O3

That's news to me. Then I googled it. You're right.

>From https://wiki.sei.cmu.edu/confluence/display/c/EXP36-C.+Do+not+cast+pointers+into+more+strictly+aligned+pointer+types

The C Standard,, paragraph 7 [ISO/IEC 9899:2011], states

A pointer to an object or incomplete type may be converted to a
pointer to a different object or incomplete type. If the resulting
pointer is not correctly aligned for the referenced type, the behavior
is undefined.


On Tue, Mar 20, 2018 at 9:41 AM, Hallvard Breien Furuseth
<h.b.furuseth@usit.uio.no> wrote:
> Looks like another type aliasing problem to me.  The data is accessed
> through an MDB_page* variable.  This tells the compiler that the data
> is word-aligned, like struct MDB_page.  Fix: Use a void/char pointer,
> don't lie to the compiler.