Fix cast of const-qualified types in FunctionThatDoesNothingImpl
Recent Clang versions fixed a bug which had previously allowed some casts that
removed qualifiers to go undiagnosed.
This fixes the following kind of error:
./../third_party/webrtc/api/optional.h:41:35: error: reinterpret_cast from
'const int *' to 'void *' casts away qualifiers
FunctionThatDoesNothingImpl(reinterpret_cast<void*>(x)));
^~~~~~~~~~~~~~~~~~~~~~~~~~
../../third_party/webrtc/api/optional.h:280:45: note: in instantiation of
function template specialization
'rtc::optional_internal::FunctionThatDoesNothing<const int>' requested here
return has_value_ ? *optional_internal::FunctionThatDoesNothing(&value_)
^
../../third_party/webrtc/call/rtp_bitrate_configurator.cc:70:53:
note: in instantiation of member function 'rtc::Optional<int>::value_or'
requested here
std::max(bitrate_config_mask_.min_bitrate_bps.value_or(0),
^
Bug: chromium:831081
Change-Id: I032ebd1f052fa2a50548e984febb7fa462df42ea
Reviewed-on: https://webrtc-review.googlesource.com/68941
Commit-Queue: Hans Wennborg <hans@chromium.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22804}
This commit is contained in:
committed by
Commit Bot
parent
6e9d89588d
commit
bda78c9464
@ -15,7 +15,7 @@ namespace optional_internal {
|
||||
|
||||
#if RTC_HAS_ASAN
|
||||
|
||||
void* FunctionThatDoesNothingImpl(void* x) {
|
||||
const void* FunctionThatDoesNothingImpl(const void* x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
@ -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 <typename T>
|
||||
inline T* FunctionThatDoesNothing(T* x) {
|
||||
return reinterpret_cast<T*>(
|
||||
FunctionThatDoesNothingImpl(reinterpret_cast<void*>(x)));
|
||||
inline const T* FunctionThatDoesNothing(T* x) {
|
||||
return reinterpret_cast<const T*>(
|
||||
FunctionThatDoesNothingImpl(reinterpret_cast<const void*>(x)));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template <typename T>
|
||||
inline T* FunctionThatDoesNothing(T* x) {
|
||||
inline const T* FunctionThatDoesNothing(T* x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user