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

[Issue]: CXX_EXTENSIONS OFF set but GNU extensions are used #119

Closed
LunNova opened this issue Jan 1, 2025 · 2 comments
Closed

[Issue]: CXX_EXTENSIONS OFF set but GNU extensions are used #119

LunNova opened this issue Jan 1, 2025 · 2 comments

Comments

@LunNova
Copy link

LunNova commented Jan 1, 2025

The CXX_EXTENSIONS property is set to off in multiple CMake files in clr, but non-standard features are used so this property should be enabled.

Most compilers silently allow extensions unless -Wpedantic or specific warnings for extensions are enabled so there's no warning by default. Adding -Wpedantic or specific warnings like Wgnu-zero-variadic-macro-arguments to CXXFLAGS finds multiple places relying on extensions.

/build/source/rocclr/utils/debug.hpp:196:64: error: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Werror,-Wgnu-zero-variadic-macro-arguments]
  196 |           amd::log_printf(      hipMemcpyHtoA
level, __FILENAME__, __LINE__, format, ##__VA_ARGS__);                   \
      |                                                       
/build/source/rocclr/platform/memory.hpp:204:5: error: anonymous structs are a GNU extension [-Werror,-Wgnu-anonymous-struct]
  204 |     struct {
      |     ^
/build/source/rocclr/platform/memory.hpp:204:5: error: anonymous types declared in an anonymous union are an extension [-Werror,-Wnested-anon-types]
@ppanchad-amd
Copy link

Hi @LunNova. Internal ticket has been created to investigate your issue. Thanks!

@sohaibnd
Copy link
Contributor

sohaibnd commented Jan 16, 2025

Hi @LunNova, setting CXX_EXTENSIONS OFF will set the -std flag in GCC to use the base standard which disables GNU extensions that do not contradict the standard specified but does not disable all GNU extensions. This is mentioned in the C Dialect Options in the GCC docs:

When a base standard is specified, the compiler accepts all programs following that standard plus those using GNU extensions that do not contradict it. For example, -std=c90 turns off certain features of GCC that are incompatible with ISO C90, such as the asm and typeof keywords, but not other GNU extensions that do not have a meaning in ISO C90, such as omitting the middle term of a ?: expression. On the other hand, when a GNU dialect of a standard is specified, all features supported by the compiler are enabled, even when those features change the meaning of the base standard. As a result, some strict-conforming programs may be rejected. The particular standard is used by -Wpedantic to identify which features are GNU extensions given that version of the standard. For example -std=gnu90 -Wpedantic warns about C++ style ‘//’ comments, while -std=gnu99 -Wpedantic does not.

so CXX_EXTENSIONS does not have to be on to use those extensions. Let me know if you have any other questions!

@LunNova LunNova closed this as completed Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants