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

            Bug ID: 91922
           Summary: #pragma pack(push,4) does not align element on 32 bit
                    boundary properly
           Product: gcc
           Version: 6.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: slightbody at ledroadwaylighting dot com
  Target Milestone: ---

Created attachment 46958
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46958&action=edit
c source

The attached small main.c results in a Hard Fault on the line *p=x; when
compiled for the Cortex M0+ processor. The u32thing element of the structure
should be aligned on a 32bit boundary in memory due to the #pragma pack(push,4)
statement, but it is not.

It appears the compiler may be being confused by the pack(1) directive later in
the structure.

Compile line:
"D:\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-gcc.exe"
 -x c -mthumb -D__SAMD21G18A__ -DNDEBUG 
-I"D:\Atmel\Studio\7.0\Packs\arm\cmsis\5.0.1\CMSIS\Include"
-I"D:\Atmel\Studio\7.0\Packs\atmel\SAMD21_DFP\1.3.304\samd21a\include"  -Os
-ffunction-sections -mlong-calls -Wall -mcpu=cortex-m0plus -c -std=gnu99 -MD
-MP -MF "main.d" -MT"main.d" -MT"main.o"   -o "main.o" ".././main.c" 

Snip of .map file (one_v) should be on a 32 bit aligned address:
 *(COMMON)
 COMMON         0x20000450        0xa main.o
                0x20000450                two
                0x20000454                abc
                0x20000455                one_v

Reply via email to