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

cc1plus: warning: '-Werror=' argument '-Werror=implicit-int' is not valid for C++ #21229

Closed
adfernandes opened this issue Dec 6, 2019 · 2 comments · Fixed by #21242
Closed
Labels
area: Build System area: C++ bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug

Comments

@adfernandes
Copy link
Contributor

I recently started testing the gcc-arm-none-eabi-9-2019-q4-major compiler in a C++ project, and came across the following for my C++ translation units:

cc1plus: warning: '-Werror=' argument '-Werror=implicit-int' is not valid for C++

This is a known change in gcc 9 and will likely is or will soon be a part of clang.

To Reproduce
Enable C++ and add a C++ file to the project.

Expected behavior
The -Werror=implicit-int option should not be enabled for C++ translation units.

Impact
This is an annoyance because Zephyr appears to really pride itself on "zero warning" builds, which is expected of possible mission- or safety-critical embedded systems.

Environment

  • macOS and Linux
  • gcc-arm-none-eabi-9-2019-q4-major
  • Zephyr v2.1.0-rc3-6-gf570f19bef

First Steps Fixing

I'm volunteering to help fix this, if some kind person can give me some pointers!

The macro toolchain_cc_warning_error_implicit_int is defined

The macro toolchain_cc_warning_error_implicit_int is enabled here

Now, following the chain:

Now the problem is (I think) that target_cc_option_fallback checks to see if the specified option is valid for C and CXX and possibly ASM. But the -Werror=implicit-int option only produces a warning, not an error in the test, so it's allowed through (for C++).

I believe that the GCC release notes say that this will soon become a build-breaking error, not a warning, so it really does need to be fixed sometime.

But for the life of me I can't decipher that kind of CMakeFoo without some help...

@adfernandes adfernandes added the bug The issue is a bug, or the PR is fixing a bug label Dec 6, 2019
@vanwinkeljan
Copy link
Member

@SebastianBoe could you provide some advice?

SebastianBoe added a commit to SebastianBoe/zephyr that referenced this issue Dec 9, 2019
We do compiler flag compatibility tests to be able to support many
different toolchains and flags in a scalable way. But the test is not
perfect and in these situations we we will need to hardcode whether a
flag is compatible or not.

To support this we have zephyr_compiler_check first check if the flag
is covered by a hardcoded test before testing it.

Currently the only hardcoded compatibilty is that -Werror=implicit-int
is not supported for CXX.

This fixes zephyrproject-rtos#21229

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
@pabigot pabigot added has-pr priority: medium Medium impact/importance bug labels Dec 10, 2019
galak pushed a commit that referenced this issue Dec 12, 2019
We do compiler flag compatibility tests to be able to support many
different toolchains and flags in a scalable way. But the test is not
perfect and in these situations we we will need to hardcode whether a
flag is compatible or not.

To support this we have zephyr_compiler_check first check if the flag
is covered by a hardcoded test before testing it.

Currently the only hardcoded compatibilty is that -Werror=implicit-int
is not supported for CXX.

This fixes #21229

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
@kyberdin
Copy link
Collaborator

I'm also encountering this issue when compiling a project with C++ sources, but with an additional warning:

cc1plus: warning: command line option '-Wno-pointer-sign' is valid for C/ObjC but not for C++
cc1plus: warning: '-Werror=' argument '-Werror=implicit-int' is not valid for C++

Not surprisingly, if I comment out target_warnings.cmake:22 and target_warnings.cmake:94 for GCC then the warnings no longer get printed.

Am I overlooking something in the configuration for disabling these warnings?

OS: Ubuntu 18.04.5
Zephyr Version: 2.3.0
Compiler Version: arm-zephyr-eabi-g++ (crosstool-NG 1.24.0.37-3f461da-dirty) 9.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Build System area: C++ bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants