[vlc-devel] [PATCH] access/dcp: AESKey::decryptyRSA: fix narrowing-conversion in case-label

Filip Roséen filip at atch.se
Sat Feb 25 07:28:21 CET 2017


narrowing-conversions are not allowed in case-statements as of C++11,
meaning that the former implementation caused standard-compliant
compilers to emit a diagnostic on the line in question.

--

    % cat testcase.cpp
    | #include <cstddef>
    | #include <limits>
    | ========
    | int main()
    | {
    |     switch( std::numeric_limits<size_t>::max() )
    |     {
    |         case -1: break;
    |     }
    | }

    % clang++ -Wall -pedantic -std=c++11 testcase.cpp
    | testcase.cpp:8:14: error: case value evaluates to -1, which cannot be narrowed to type 'unsigned long' [-Wc++11-narrowing]
    |         case -1: break;
    |              ^
    | 1 error generated.

If interested, see `[stmt.switch]p2` and `[expr.const]p3` (*N3290*).
---
 modules/access/dcp/dcpdecrypt.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/access/dcp/dcpdecrypt.cpp b/modules/access/dcp/dcpdecrypt.cpp
index e7dcaa9195..88cce85205 100644
--- a/modules/access/dcp/dcpdecrypt.cpp
+++ b/modules/access/dcp/dcpdecrypt.cpp
@@ -327,7 +327,7 @@ int AESKey::decryptRSA( string s_cipher_text_b64 )
             if( this->extractInfo( ps_plain_text, false ) )
                 goto end;
             break;
-        case -1:
+        case static_cast<size_t>( -1 ):
             msg_Err( this->p_demux, "could not decrypt" );
             goto end;
         default:
-- 
2.11.1



More information about the vlc-devel mailing list