diff --git a/api/include/opentelemetry/trace/span_id.h b/api/include/opentelemetry/trace/span_id.h index e282a2021a..fe2953a0b3 100644 --- a/api/include/opentelemetry/trace/span_id.h +++ b/api/include/opentelemetry/trace/span_id.h @@ -61,7 +61,8 @@ class SpanId final 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.