diff --git a/rerun_cpp/src/rerun/compiler_utils.hpp b/rerun_cpp/src/rerun/compiler_utils.hpp index 8aae606bc42a..c6ea5724ae9d 100644 --- a/rerun_cpp/src/rerun/compiler_utils.hpp +++ b/rerun_cpp/src/rerun/compiler_utils.hpp @@ -52,3 +52,10 @@ #else #define RR_DISABLE_DEPRECATION_WARNING #endif + +// Disable possible null reference warning +#if defined(__GNUC__) || defined(__clang__) +#define RR_DISABLE_NULL_DEREF_WARNING _Pragma("GCC diagnostic ignored \"-Wnull-dereference\"") +#else +#define RR_DISABLE_NULL_DEREF_WARNING +#endif diff --git a/rerun_cpp/src/rerun/component_column.cpp b/rerun_cpp/src/rerun/component_column.cpp index 70b637eb9273..9f3bcf7e9523 100644 --- a/rerun_cpp/src/rerun/component_column.cpp +++ b/rerun_cpp/src/rerun/component_column.cpp @@ -2,6 +2,7 @@ #include "arrow_utils.hpp" #include "c/rerun.h" +#include "compiler_utils.hpp" #include #include @@ -20,7 +21,12 @@ namespace rerun { ) { // Convert lengths into offsets. std::vector offsets(lengths.size() + 1); + // Some GCC versions see ghosts here - this can't be a null dereference since we have at least 1 element. + RR_PUSH_WARNINGS + RR_DISABLE_NULL_DEREF_WARNING offsets[0] = 0; + RR_POP_WARNINGS + for (size_t i = 0; i < lengths.size(); i++) { offsets[i + 1] = offsets[i] + lengths[i]; }