https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107498
Bug ID: 107498 Summary: Wrong optimization leads to unaligned access when compiling OpenLDAP Product: gcc Version: 12.2.0 URL: https://bugs.openldap.org/show_bug.cgi?id=9916 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: glaubitz at physik dot fu-berlin.de CC: ebotcazou at gcc dot gnu.org, jrtc27 at jrtc27 dot com, matorola at gmail dot com, slyfox at gcc dot gnu.org Target Milestone: --- Target: sparc64-*-* Building OpenLDAP on sparc64-linux-gnu using gcc-12 results in a slapd binary that crashes with unaligned access ("Bus error"). After investigation, it turned out that this is not a bug in the OpenLDAP code but gcc-12 which tries to optimize a access to two 2-byte fields in a struct using a 4-byte store instruction. This fails because the 2-byte fields have only 2-byte alignment. More details on the issue can be obtained from the corresponding OpenLDAP bug report, in particular comment #10 [1]. > [1] https://bugs.openldap.org/show_bug.cgi?id=9916#c10