[issue15495] enable type truncation warnings for gcc builds

Martin Panter report at bugs.python.org
Thu Aug 11 08:52:34 EDT 2016


Martin Panter added the comment:

Issue 23545 has a patch with some comments from me about adding other warnings via “autoconf foo”, so you could copy from that if you want.

The few warnings that I glanced at do not look troublesome. But maybe it is worth working around them to see other warnings; I dunno. Adding explicit casts can sometimes hide other bugs. Anyway, here is a random selection of some warnings:

Modules/sha256module.c:198:44: warning: conversion to ‘SHA_INT32 {aka unsigned int}’ from ‘long unsigned int’ may alter its value [-Wconversion]
     RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],48,0x19a4c116);
                                            ^
Modules/sha256module.c:145:11: note: in definition of macro ‘RND’
      t0 = h + Sigma1(e) + Ch(e, f, g) + ki + W[i];   \
           ^
Modules/resource.c:19:60: warning: conversion to ‘double’ from ‘__suseconds_t {aka long int}’ may alter its value [-Wconversion]
 #define doubletime(TV) ((double)(TV).tv_sec + (TV).tv_usec * 0.000001)
                                                            ^
./Include/tupleobject.h:62:75: note: in definition of macro ‘PyTuple_SET_ITEM’
 #define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v)
                                                                           ^
Modules/resource.c:82:5: note: in expansion of macro ‘PyStructSequence_SET_ITEM’
     PyStructSequence_SET_ITEM(result, 0,
     ^~~~~~~~~~~~~~~~~~~~~~~~~
Modules/resource.c:83:40: note: in expansion of macro ‘doubletime’
                     PyFloat_FromDouble(doubletime(ru.ru_utime)));
                                        ^~~~~~~~~~
Modules/cjkcodecs/cjkcodecs.h:155:27: warning: conversion to ‘unsigned char’ from ‘int’ may alter its value [-Wconversion]
     do { ((*outbuf)[1]) = (c); } while (0)
                           ^
Modules/cjkcodecs/_codecs_kr.c:58:13: note: in expansion of macro ‘OUTBYTE2’
             OUTBYTE2((code & 0xFF) | 0x80);
             ^~~~~~~~
Modules/_ctypes/cfield.c:439:15: warning: conversion to ‘short int’ from ‘int’ may alter its value [-Wconversion]
         v >>= (sizeof(v)*8 - NUM_BITS(size));                           \
               ^
Modules/_ctypes/cfield.c:594:5: note: in expansion of macro ‘GET_BITFIELD’
     GET_BITFIELD(val, size);
     ^~~~~~~~~~~~

----------
nosy: +martin.panter

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15495>
_______________________________________


More information about the Python-bugs-list mailing list