googletest
googletest copied to clipboard
[Bug]: "<ciso646> is deprecated in C++17, use <version> to detect implementation-specific macros" on fedora:rawhide
Describe the issue
On latest fedora:rawhide, both with clang++ (19.1.6) or g++ (15.0.1), in implicit mode or explicit -std=c++17, including gtest.h emits:
/usr/bin/../lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/ciso646:46:4: warning: "<ciso646> is deprecated in C++17, use <version> to detect implementation-specific macros"
46 | # warning "<ciso646> is deprecated in C++17, use <version> to detect implementation-specific macros"
| ^
workaround: use explicit -std=c++20
Steps to reproduce the problem
docker run --rm -it fedora:rawhide
install gtest 1.15.2 in it include gtest.h
What version of GoogleTest are you using?
1.15.2
What operating system and version are you using?
# cat /etc/redhat-release
Fedora release 41 (Rawhide)
What compiler and version are you using?
clang++ (19.1.6) or g++ (15.0.1)
What build system are you using?
all
Additional context
No response
From cppreference:
is removed in C++20. Corresponding <iso646.h> is still available in C++20.
Sounds like we can just change https://github.com/google/googletest/blob/4a00a24fff3cf82254de382437bf840cab1d3993/googletest/include/gtest/internal/gtest-port.h#L295
to #include <iso646.h>.
@rouault Could you try if that fixes the warning?
I just tested the following:
# dnf install clang
# echo "#include <iso646.h>" > test.cc
# clang++ -std=c++17 -c test.cc
# g++ -std=c++17 -c test.cc
Hi,
FYI, fedora has applied this change: https://src.fedoraproject.org/rpms/gtest/c/b3fe6f803a1e554971f70e1c3f55aa5fcb377b1b?branch=rawhide (ie include <version> if this header exists, then fallback to using <cerrno>
Looks like this fix has been applied?
https://github.com/google/googletest/blob/3fbe4db9a39291ae8d7a9c5f1d75896bb4c5a18f/googletest/include/gtest/internal/gtest-port.h#L288