diff --git a/api/include/opentelemetry/trace/span_id.h b/api/include/opentelemetry/trace/span_id.h index e282a2021a..63d2f36894 100644 --- a/api/include/opentelemetry/trace/span_id.h +++ b/api/include/opentelemetry/trace/span_id.h @@ -60,8 +60,8 @@ class SpanId final // Returns false if the SpanId is all zeros. bool IsValid() const noexcept { - static_assert(kSize == 8, "update is needed if kSize is not 8"); - return *reinterpret_cast(&rep_) != 0ull; + static constexpr uint8_t kEmptyRep[kSize] = {0}; + return memcmp(rep_, kEmptyRep, kSize) != 0; } // Copies the opaque SpanId data to dest.