From 9305594574b00cefd51caea860cb85eaeef06f27 Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Sat, 6 Jan 2018 19:03:58 +0000 Subject: [PATCH] Use _Pragma to turn off invalid-offsetof warnings at appropriate places. This means that we no longer need to build with -Wno-invalid-offsetof. --- mconfig | 2 +- src/control.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/mconfig b/mconfig index b9a65e2..fed7a66 100644 --- a/mconfig +++ b/mconfig @@ -1,7 +1,7 @@ # Linux (GCC). Note with GCC 5.x/6.x you must use the old ABI, with GCC 7.x you must use # the new ABI. See BUILD file for more information. CXX=g++ -CXXOPTS=-D_GLIBCXX_USE_CXX11_ABI=1 -std=gnu++11 -Os -Wall -Wno-invalid-offsetof -fno-rtti +CXXOPTS=-D_GLIBCXX_USE_CXX11_ABI=1 -std=gnu++11 -Os -Wall -fno-rtti EXTRA_LIBS= BUILD_SHUTDOWN=yes SANITIZEOPTS=-fsanitize=address,undefined diff --git a/src/control.h b/src/control.h index a6389f3..efcd72a 100644 --- a/src/control.h +++ b/src/control.h @@ -218,8 +218,13 @@ class control_conn_t : private service_listener static rearm control_conn_cb(eventloop_t * loop, control_conn_watcher * watcher, int revents) { + // Get the address of the containing control_connt_t object: + _Pragma ("GCC diagnostic push") + _Pragma ("GCC diagnostic ignored \"-Winvalid-offsetof\"") char * cc_addr = (reinterpret_cast(watcher)) - offsetof(control_conn_t, iob); control_conn_t *conn = reinterpret_cast(cc_addr); + _Pragma ("GCC diagnostic pop") + if (revents & IN_EVENTS) { if (conn->data_ready()) { delete conn; -- 2.25.1