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

[Bug]: GTEST_INTERNAL_HAVE_CPP_ATTRIBUTE is not accounting for the standard in which attribute is introduced #4605

Open
maikelvdh opened this issue Aug 26, 2024 · 0 comments

Comments

@maikelvdh
Copy link

Describe the issue

The GTEST_INTERNAL_HAVE_CPP_ATTRIBUTE is not evaluating against the C++ standard in which an attribute is introduced. Currently the only usage is in context of GTEST_INTERNAL_HAVE_CPP_ATTRIBUTE(maybe_unused) which could lead in context of C++14 to usage maybe_unused which is only applicable from C++17 onwards. Usage of this could be leading to -Wc++17-attribute-extensions warning.

More robust approach would be therefore be:

#define GTEST_INTERNAL_HAVE_CPP_ATTRIBUTE(x) __cplusplus >= __has_cpp_attribute(x)

Steps to reproduce the problem

Compile googletest repository from root like:

$ CXXFLAGS="-Werror -Wall -Wextra -Wpedantic" cmake -DCMAKE_CXX_STANDARD=14 . -B /tmp/gtestbuildfolder/
$ cmake --build /tmp/gtestbuildfolder/

What version of GoogleTest are you using?

1.15.2

What operating system and version are you using?

macOS Sonoma 14.6

What compiler and version are you using?

Apple clang version 15.0.0 (clang-1500.0.40.1)

What build system are you using?

cmake version 3.30.2

Additional context

No response

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

No branches or pull requests

5 participants
@maikelvdh and others