From d81dc49c5be9a9322bdd47aef050a456e759a9f6 Mon Sep 17 00:00:00 2001 From: brucedawson Date: Fri, 1 Apr 2016 10:16:14 -0700 Subject: [PATCH] Fix C4434 warning about 32-bit shift assigned to 64-bits VS 2015 has a new or louder warning about 32-bit shifts that are then assigned to a 64-bit target. This type of code triggers it: int64_t size = 1 << shift_amount; Because the '1' being shifted is a 32-bit int the result of the shift will be a 32-bit result, so assigning it to a 64-bit variable is just misleading. In this case the code that triggers it is this: size_t window_size = static_cast(1 << shift_amount); The destination is a size_t so the warning only shows up on 64-bit builds and doesn't indicate a real bug. It's curious that the code had a cast already - presumably to suppress some other warning - but the cast is not in the ideal place and doesn't avoid this new warning. Moving the cast allows shift_amount to be log2(size_t) and allows enabling C4334 in Chromium. BUG=593448 Review URL: https://codereview.webrtc.org/1849753004 Cr-Commit-Position: refs/heads/master@{#12199} --- .../intelligibility/intelligibility_enhancer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer.cc b/webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer.cc index 04d3654521..268b77b93b 100644 --- a/webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer.cc +++ b/webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer.cc @@ -93,7 +93,7 @@ IntelligibilityEnhancer::IntelligibilityEnhancer(int sample_rate_hz, 43.f)); start_freq_ = std::max(static_cast(1), erb_index * kErbResolution); - size_t window_size = static_cast(1 << RealFourier::FftOrder(freqs_)); + size_t window_size = static_cast(1) << RealFourier::FftOrder(freqs_); std::vector kbd_window(window_size); WindowGenerator::KaiserBesselDerived(kKbdAlpha, window_size, kbd_window.data());