Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
claudiocabral opened this issue May 15, 2020 · 0 comments

Comments

@claudiocabral
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant