arduino / arduino/ArduinoCore-avr

PROGMEM attribute ignored for implicit pointer initialization

Open
#278 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
1.5k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

Windows Arduino IDE 1.8.9, default settings.

**Description:**
bellow both statements are identical. In both cases we get array of pointers, where all elements will be NULL pointers. And both variables occupies identical size 20 byte in SRAM
`const char *const list[10];`
`const char *const list[10] = {NULL};`

BUT

**Actual behavior:**
if we will try put it in Flash then for first one, PROGMEM attribute is ignored and it will be placed only in SRAM instead of PROGMEM
`const PROGMEM char *const list[10]; // will be placed in SRAM. progmem ignored`
`const PROGMEM char *const list[10] = {NULL}; // will be placed in PROGMEM`

**Expected behavior:**
`const PROGMEM char *const list[10];` should be placed in Flash

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the two declarations in Windows Arduino IDE 1.8.9 and compare their SRAM and Flash placement. Investigate how PROGMEM is handled for an implicitly initialized pointer array; done means the uninitialized form is placed in Flash like the {NULL} form without changing the expected NULL elements.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.