]> granicus.if.org Git - python/commitdiff
bpo-26219: Fix compiler warning in _PyCode_InitOpcache() (GH-13809)
authorVictor Stinner <vstinner@redhat.com>
Tue, 4 Jun 2019 15:08:24 +0000 (17:08 +0200)
committerGitHub <noreply@github.com>
Tue, 4 Jun 2019 15:08:24 +0000 (17:08 +0200)
Fix this MSVC warning:

    objects\codeobject.c(264): warning C4244: '=':
    conversion from 'Py_ssize_t' to 'unsigned char', possible loss of data

Objects/codeobject.c

index 0d9e5d16e768152e0d581e07ad6d24a875657eeb..63ce4793597a134d5c36499e1c4a4af0f1b4f8ca 100644 (file)
@@ -261,7 +261,8 @@ _PyCode_InitOpcache(PyCodeObject *co)
 
         // TODO: LOAD_METHOD, LOAD_ATTR
         if (opcode == LOAD_GLOBAL) {
-            co->co_opcache_map[i] = ++opts;
+            opts++;
+            co->co_opcache_map[i] = (unsigned char)opts;
             if (opts > 254) {
                 break;
             }