3

I have the following definitions:

static char xxxx;
static uint8_t y;

I am getting the following lines in the memory map:

.bss._ZZL7createXvE4xxxx 0x200024c0        0x1
.bss._ZZL7createXvE11y   0x200024c1        0x1

If I change it to the following:

static char xxxx;
static uint8_t y[1];

I am getting the following lines in the memory map:

.bss._ZZL7createXvE4xxxx 0x200024c0        0x1
fill                     0x200024c1        0x3
.bss._ZZL7createXvE11y   0x200024c4        0x1

Is this a well known behaviour that GCC will always align the start address for an array?

as described above, expected same result but it is different

1 Answer 1

1

As an update, I got the following response when asked on the GCC website:

"It's not part of the ABI, but there can be performance benefits from aligning arrays, for example when code is vectorized. It's not possible to easily tell exactly how large the array will be in practice, so even very small ones get aligned.

There's no point in doing this for scalar objects as the next location cannot ever contain a related object."

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.