https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89208
Bug ID: 89208 Summary: unaligned access expanded to memcpy Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: bernd.edlinger at hotmail dot de Target Milestone: --- This test case is mis-compiled: $ cat unaligned-argument-3.c /* { dg-do compile } */ /* { dg-options "-ffreestanding -marm -march=armv6 -mno-unaligned-access -mfloat-abi=soft -mabi=aapcs -O3" } */ struct s { int a, b; } __attribute__((packed)); void f(struct s *a, struct s *b) { *a = *b; } /* { dg-final { scan-assembler-times "ldrd" 0 } } */ /* { dg-final { scan-assembler-times "strd" 0 } } */ /* { dg-final { scan-assembler-times "ldm" 0 } } */ /* { dg-final { scan-assembler-times "stm" 0 } } */ /* { dg-final { scan-assembler-times "memcpy" 0 } } */ $ arm-linux-gnueabihf-gcc -ffreestanding -marm -march=armv6 -mno-unaligned-access -mfloat-abi=soft -mabi=aapcs -O3 -S unaligned-argument-3.c $ $ cat unaligned-argument-3.s .arch armv6 .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, 2 .eabi_attribute 34, 0 .eabi_attribute 18, 4 .file "unaligned-argument-3.c" .text .align 2 .global f .syntax unified .arm .fpu softvfp .type f, %function f: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 mov r2, #8 push {r4, lr} bl memcpy pop {r4, pc} .size f, .-f .ident "GCC: (GNU) 9.0.1 20190128 (experimental)" .section .note.GNU-stack,"",%progbits it is wrong to call memcpy if -ffreestanding is used.