diff --git a/api/optional.cc b/api/optional.cc index 94126170a5..0f74bd2446 100644 --- a/api/optional.cc +++ b/api/optional.cc @@ -15,7 +15,7 @@ namespace optional_internal { #if RTC_HAS_ASAN -void* FunctionThatDoesNothingImpl(void* x) { +const void* FunctionThatDoesNothingImpl(const void* x) { return x; } diff --git a/api/optional.h b/api/optional.h index 9221f2c0b5..ba06831a29 100644 --- a/api/optional.h +++ b/api/optional.h @@ -33,18 +33,18 @@ namespace optional_internal { // This is a non-inlined function. The optimizer can't see inside it. It // prevents the compiler from generating optimized code that reads value_ even // if it is unset. Although safe, this causes memory sanitizers to complain. -void* FunctionThatDoesNothingImpl(void*); +const void* FunctionThatDoesNothingImpl(const void*); template -inline T* FunctionThatDoesNothing(T* x) { - return reinterpret_cast( - FunctionThatDoesNothingImpl(reinterpret_cast(x))); +inline const T* FunctionThatDoesNothing(T* x) { + return reinterpret_cast( + FunctionThatDoesNothingImpl(reinterpret_cast(x))); } #else template -inline T* FunctionThatDoesNothing(T* x) { +inline const T* FunctionThatDoesNothing(T* x) { return x; }