diff --git a/api/include/opentelemetry/trace/span_id.h b/api/include/opentelemetry/trace/span_id.h index c05a4c6829..e282a2021a 100644 --- a/api/include/opentelemetry/trace/span_id.h +++ b/api/include/opentelemetry/trace/span_id.h @@ -58,7 +58,11 @@ class SpanId final bool operator!=(const SpanId &that) const noexcept { return !(*this == that); } // Returns false if the SpanId is all zeros. - bool IsValid() const noexcept { return *this != SpanId(); } + bool IsValid() const noexcept + { + static_assert(kSize == 8, "update is needed if kSize is not 8"); + return *reinterpret_cast(&rep_) != 0ull; + } // Copies the opaque SpanId data to dest. void CopyBytesTo(nostd::span dest) const noexcept