[Bug middle-end/107498] Wrong optimization leads to unaligned access when compiling OpenLDAP

ebotcazou at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Nov 13 10:14:58 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107498

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|---                         |INVALID

--- Comment #9 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> Program received signal SIGBUS, Bus error.
> 0x00000100000ceda4 in mdb_node_add (mc=0x100004327b8, indx=<optimized out>,
> key=0x7feffffe0a0, data=0x7feffffe090, pgno=0, flags=0) at
> ./../../../libraries/liblmdb/mdb.c:7366
> 7366            mp->mp_lower += sizeof(indx_t);
> (gdb) p mp
> $1 = (MDB_page *) 0x10000463caa

Thanks.  So that's definitely *not* a compiler bug but a programming error as
per the 6.5.3.2(4) clause of the ISO C standard:

"The unary * operator denotes indirection. If the operand points to a function,
the result is a function designator; if it points to an object, the result is
an lvalue designating the object. If the operand has type "pointer to type",
the result has type "type". If an invalid value has been assigned to the
pointer, the behavior of the unary * operator is undefined.(106)"

(106)
Among the invalid values for dereferencing a pointer by the unary * operator
are a null pointer, an address inappropriately aligned for the type of object
pointed to, and the address of an object after the end of its lifetime.


More information about the Gcc-bugs mailing list