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

Error compiling C++ with flag (-Wmissing-field-initializers) #67396

Closed
yperess opened this issue Jan 9, 2024 · 4 comments
Closed

Error compiling C++ with flag (-Wmissing-field-initializers) #67396

yperess opened this issue Jan 9, 2024 · 4 comments
Assignees
Labels
area: C++ bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug

Comments

@yperess
Copy link
Collaborator

yperess commented Jan 9, 2024

Describe the bug
When using -Wmissing-field-initializers to compile Zephyr we get and error for SYS_INIT since it doesn't initialize the dev field

To Reproduce
Steps to reproduce the behavior:

  1. Add -Wmissing-field-initializers to the compile options and build any app with SYS_INIT

Expected behavior
Should build

Impact
Breaks build

@yperess yperess added bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug labels Jan 9, 2024
@yperess yperess self-assigned this Jan 9, 2024
@yperess
Copy link
Collaborator Author

yperess commented Jan 31, 2024

Fixed in #68125

@yperess yperess closed this as completed Jan 31, 2024
@marc-hb
Copy link
Collaborator

marc-hb commented Feb 25, 2024

Re-opening because this flag broke again:

If this policy is not formally agreed and regularly enforced in CI then it will keep breaking. From #68118 (comment)

@barnas-michal not related to this being the right way to "fix" or not, but we should not be fixing issues of compiler warnings only enabled outside of the project, if this compiler flag is useful we should enable it in zephyr as well and fix issues everywhere and deal with it within the project for all toolchains and support this accordingly.

More relevant discussion in

Copy link

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

@github-actions github-actions bot added the Stale label Apr 26, 2024
@marc-hb marc-hb removed the Stale label Apr 26, 2024
@marc-hb
Copy link
Collaborator

marc-hb commented Jun 16, 2024

init.h fixed for good in a portable way in:

Solution thoroughly documented in:

Note that new documentation does NOT say anything about -Wmissing-field-initializers, which is not required by any C or C++ version. Both languages guarantee that missing fields will be initialized to zero (or equivalent).

@ceolin is -Wmissing-field-initializers something MISRA requires?

@marc-hb marc-hb closed this as completed Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: C++ bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants