Fixed #2272: Compilation failure with C++20#2297
Conversation
This commit fixes issue catchorg#2272: Compilation failure with C++20. To do this, it removes using-declarations for deprecated functions std::allocator<T>::address(), construct(), max_size(), and destroy() from the CustomAllocator class in Matchers.tests.cpp; and it wraps the use of a comma operator inside the bracket operator in Message.tests.cpp. This commit also updates compact.sw.approved.txt, console.sw.approved.txt, and xml.sw.approved.txt to reflect the change made in Message.tests.cpp. Signed-off-by: Alecto Irene Perez <perez.cs@pm.me>
Ah, MSVC, my old nemesis, we meet again. This commit amends the previous commit to re-introduce the following using declarations inside the CustomAllocator class: - using std::allocator<T>::address; - using std::allocator<T>::construct; - using std::allocator<T>::max_size; - using std::allocator<T>::destroy; When building with MSVC and using a C++ standard older than C++17. These were re-introduced because MSVC throws an error if they're not present when compiling with C++11 or C++14. Signed-off-by: Alecto Irene Perez <perez.cs@pm.me>
Codecov Report
@@ Coverage Diff @@
## v2.x #2297 +/- ##
=======================================
Coverage 90.09% 90.09%
=======================================
Files 113 113
Lines 5035 5035
=======================================
Hits 4536 4536
Misses 499 499 |
horenmar
left a comment
There was a problem hiding this comment.
Thanks, but the fixes should be done a bit differently (see comments)
This commit restores the previous state of 'CAPTURE can deal with complex expressions involving commas', and instead uses localized warning suppression to disable messages warnings about the use of a comma inside a bracket operator. Signed-off-by: Alecto Irene Perez <perez.cs@pm.me>
I added localized warning suppression and restored the initial state of the test!
That was my initial assumption too, but this broke in MSVC 2015, which checked for the existence of those methods. Since these methods become deprecated in C++17, I added a |
|
Thanks |
It turns out that Issue catchorg#2272 partially affected the devel branch. When building tests with C++20, the compiler emits a warning that top-level comma expressions in array subscripts are depricated. Warnings are treated as errors, so this caused the build to fail. This commit adds localized warning suppression in accordance with this recommendation here: catchorg#2297 (comment) Signed-off-by: Alecto Irene Perez <perez.cs@pm.me>
* Apply PR #2297 to devel branch It turns out that Issue #2272 partially affected the devel branch. When building tests with C++20, the compiler emits a warning that top-level comma expressions in array subscripts are depricated. Warnings are treated as errors, so this caused the build to fail. This commit adds localized warning suppression in accordance with this recommendation here: #2297 (comment) Signed-off-by: Alecto Irene Perez <perez.cs@pm.me> * Fixed unknown pragma warning on old versions of gcc & clang This commit fixes an unkwown pragma warning on older versions of GCC and Clang. These older versions don't have a warning for depricated use of the comma subscript. Because warning suppression is localized, and only refers to the comma subscript warning, it doesn't affect compiler warnings in other parts of the code. Signed-off-by: Alecto Irene Perez <perez.cs@pm.me> * More #warning backwards compatibility fixes Signed-off-by: Alecto Irene Perez <perez.cs@pm.me>
Description
This commit fixes issue #2272: Compilation failure with C++20.
To do this, it removes using-declarations for
std::allocator<T>::address(),std::allocator<T>::construct(),std::allocator<T>::max_size(), andstd::allocator<T>::destroy()from the CustomAllocator class in Matchers.tests.cpp. These functions were deprecated in C++17, and removed in C++20, so having a using declaration for them causes compilation error. The functions weren't used in the Catch2 code base in earlier versions of C++, so it's not a breaking change.
This commit also wraps the use of a comma operator inside the bracket operator in Message.tests.cpp. This change is necessary because gcc was issuing an error when compiling tests with
-std=c++20.Becomes
Click to see compilation error
This commit also ran
scripts/approve.py, which updated compact.sw.approved.txt, console.sw.approved.txt, and xml.sw.approved.txt to reflect the change made in Message.tests.cpp.GitHub Issues
This PR was motivated by #2272