robertwb / issues-import-test

0 stars 0 forks source link

Compiler warnings in `__Pyx_decode_c_string` with `-Wsign-conversion` #97

Closed robertwb closed 7 years ago

robertwb commented 7 years ago

Reported by nikratio on 11 Sep 2015 23:05 UTC The code generated by Cython 0.23.1 for the __Pyx_decode_c_string function triggers the following compiler warning:

src/llfuse.c: In function __Pyx_decode_c_string:
src/llfuse.c:41294:18: error: conversion to Py_ssize_t from size_t may change the sign of the result [-Werror=sign-conversion]
         length = strlen(cstring);
                  ^

It'd be great if Cython generated C would compile without warnings.

This can be reproduced with pretty much any Cython file, for example:

$ cat smalltest.pyx
cdef char *s
s = "Hello, world"
foo = s.decode()

Migrated-From: http://trac.cython.org/ticket/864

robertwb commented 7 years ago

Comment by scoder on 12 Sep 2015 19:08 UTC The C-API uses Py_ssize_t here (even the stateful decoders), so larger values should raise an exception. CPython raises OverflowError in similar cases (e.g. PyUnicode_FromString()).

robertwb commented 7 years ago

Comment by scoder on 12 Sep 2015 20:44 UTC Fix implemented here: https://github.com/cython/cython/pull/444

robertwb commented 7 years ago

Modified by scoder on 12 Sep 2015 20:45 UTC