Skip to content

-Werror=maybe-uninitialized on file system/page_storage.h with gcc 9 #2

@claudiocabral

Description

@claudiocabral

compiling with gcc-arm-none-eabi-9-2019-q4-major fails with the following error:

./stmlib/system/page_storage.h: In member function 'bool plaits::Settings::Init()':
./stmlib/system/page_storage.h:185:24: error: '*((void*)& h +4)' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  185 |       FLASH_ProgramWord(address, *words);
      |       ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
./stmlib/system/page_storage.h:171:17: note: '*((void*)& h +4)' was declared here
  171 |     ChunkHeader h;
      |                 ^

The compiler gets confused because ChunkHeader doesn't default intiialize its varibles and fails to see the assignments next to it.
The fix is to use the initializer_list constructor instead of manually assigning the variables

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions