[Bug middle-end/88085] User alignments on var decls not respected if smaller than type alignment

petro.karashchenko at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Sep 2 11:04:03 GMT 2021


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

--- Comment #20 from Petro Karashchenko <petro.karashchenko at gmail dot com> ---
I just checked next case

typedef int tolerant_int __attribute__((aligned(1)));
tolerant_int var;

int foo(void)
{
  return var;
}
----------------------------------
arm-none-eabi-gcc -save-temps -Wall -Wextra -c -mcpu=arm7tdmi -mthumb test.c
-O0
----------------------------------
        .cpu arm7tdmi
        .eabi_attribute 20, 1
        .eabi_attribute 21, 1
        .eabi_attribute 23, 3
        .eabi_attribute 24, 1
        .eabi_attribute 25, 1
        .eabi_attribute 26, 1
        .eabi_attribute 30, 6
        .eabi_attribute 34, 0
        .eabi_attribute 18, 4
        .file   "test.c"
        .text
        .comm   var,4,1
        .align  1
        .global foo
        .arch armv4t
        .syntax unified
        .code   16
        .thumb_func
        .fpu softvfp
        .type   foo, %function
foo:
        @ Function supports interworking.
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 1, uses_anonymous_args = 0
        push    {r7, lr}
        add     r7, sp, #0
        ldr     r3, .L3
        ldr     r3, [r3]
        movs    r0, r3
        mov     sp, r7
        @ sp needed
        pop     {r7}
        pop     {r1}
        bx      r1
.L4:
        .align  2
.L3:
        .word   var
        .size   foo, .-foo
        .ident  "GCC: (GNU Tools for Arm Embedded Processors 9-2019-q4-major)
9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599]"
---------------------------------

So seems the alignment decrease does not work on types.


More information about the Gcc-bugs mailing list