-
Notifications
You must be signed in to change notification settings - Fork 844
Closed
Labels
Buildwork related to build configuration or environmentwork related to build configuration or environment
Milestone
Description
I tried to build ATS in C++23 standard, just because. And I got a couple of warnings and errors. The spec has not been finalized yet and the compiler might be wrong, so just a note for now.
$ c++ --version
c++ (GCC) 12.2.1 20221121 (Red Hat 12.2.1-4)
Enabled options:
--enable-werror
--enable-debug
--enable-asan
--enable-ccache
Ptr::operator== FIXED
Ptr::operator==Error
In file included from /home/mkitajo/src/trafficserver/iocore/eventsystem/I_EventSystem.h:31,
from /home/mkitajo/src/trafficserver/iocore/eventsystem/P_EventSystem.h:36,
from ../../include/records/P_RecProcess.h:30,
from RecRawStats.cc:25:
/home/mkitajo/src/trafficserver/iocore/eventsystem/I_IOBuffer.h: In member function ‘IOBufferChain& IOBufferChain::operator+=(const self_type&)’:
/home/mkitajo/src/trafficserver/iocore/eventsystem/I_IOBuffer.h:1412:18: error: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second: [-Werror]
1412 | if (nullptr == _head)
| ^~~~~
In file included from /home/mkitajo/src/trafficserver/iocore/eventsystem/I_IOBuffer.h:45:
../../include/tscore/Ptr.h:276:1: note: candidate 1: ‘bool operator==(std::nullptr_t, const Ptr<T>&) [with T = IOBufferBlock; std::nullptr_t = std::nullptr_t]’
276 | operator==(std::nullptr_t, Ptr<T> const &rhs)
| ^~~~~~~~
../../include/tscore/Ptr.h:117:3: note: candidate 2: ‘int Ptr<T>::operator==(const T*) [with T = IOBufferBlock]’ (reversed)
117 | operator==(const T *p)
| ^~~~~~~~
cc1plus: all warnings being treated as errors
Possible solution
diff --git a/iocore/eventsystem/I_IOBuffer.h b/iocore/eventsystem/I_IOBuffer.h
index b179d8051..abccf14da 100644
--- a/iocore/eventsystem/I_IOBuffer.h
+++ b/iocore/eventsystem/I_IOBuffer.h
@@ -1409,7 +1409,7 @@ IOBufferChain::operator=(self_type const &that)
inline IOBufferChain &
IOBufferChain::operator+=(self_type const &that)
{
- if (nullptr == _head)
+ if (static_cast<IOBufferBlock *>(nullptr) == _head)
*this = that;
else {
_tail->next = that._head;Arithmetic between different enumeration types ‘TSEvent’ and ‘TSHttpHookID’
Error
HttpSM.cc: In member function ‘int HttpSM::state_api_callout(int, void*)’:
HttpSM.cc:1566:51: error: arithmetic between different enumeration types ‘TSEvent’ and ‘TSHttpHookID’ is deprecated [-Werror=deprecated-enum-enum-conversion]
1566 | hook->invoke(TS_EVENT_HTTP_READ_REQUEST_HDR + cur_hook_id, this);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
Possible solution
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index 8d352eaae..2d49e59f8 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -1563,7 +1563,7 @@ plugins required to work with sni_routing.
api_timer = Thread::get_hrtime();
}
- hook->invoke(TS_EVENT_HTTP_READ_REQUEST_HDR + cur_hook_id, this);
+ hook->invoke(TS_EVENT_HTTP_READ_REQUEST_HDR + static_cast<int>(cur_hook_id), this);
if (api_timer > 0) { // true if the hook did not call TxnReenable()
this->milestone_update_api_time();
api_timer = -Thread::get_hrtime(); // set in order to track non-active callout durationArithmetic between different enumeration types ‘TSParseResult’ and ‘ORIG_TSParseResult’
Error
CXX traffic_server/traffic_server-InkAPITest.o
traffic_server/InkAPITest.cc: In function ‘void RegressionTest_SDK_API_TSConstant(RegressionTest*, int, int*)’:
traffic_server/InkAPITest.cc:6557:12: error: arithmetic between different enumeration types ‘TSParseResult’ and ‘ORIG_TSParseResult’ is deprecated [-Werror=deprecated-enum-enum-conversion]
6557 | if (_x - ORIG_##_x != 0) { \
| ^
traffic_server/InkAPITest.cc:6752:3: note: in expansion of macro ‘PRINT_DIFF’
6752 | PRINT_DIFF(TS_PARSE_ERROR);
| ^~~~~~~~~~
Possible solution
diff --git a/src/traffic_server/InkAPITest.cc b/src/traffic_server/InkAPITest.cc
index da277bd45..5e198d609 100644
--- a/src/traffic_server/InkAPITest.cc
+++ b/src/traffic_server/InkAPITest.cc
@@ -6554,7 +6554,7 @@ REGRESSION_TEST(SDK_API_TSMgmtGet)(RegressionTest *test, int /* atype ATS_UNUSED
#define PRINT_DIFF(_x) \
{ \
- if (_x - ORIG_##_x != 0) { \
+ if (static_cast<int>(_x) - static_cast<int>(ORIG_##_x) != 0) { \
test_passed = false; \
SDK_RPRINT(test, "##_x", "TestCase1", TC_FAIL, "%s:Original Value = %d; New Value = %d \n", #_x, _x, ORIG_##_x); \
}Metadata
Metadata
Assignees
Labels
Buildwork related to build configuration or environmentwork related to build configuration or environment