blue-oil / blueoil

Bring Deep Learning to small devices
https://blueoil.org
Apache License 2.0
248 stars 86 forks source link

The format specifier of std::sprintf is incorrect #1192

Open lm-kasuga opened 4 years ago

lm-kasuga commented 4 years ago

The variable len is int, but %u is used. This may cause UB(but the compiler doesn't say any errors or warnings. ref. https://stackoverflow.com/questions/11303784/why-doesnt-gcc-wformat-warn-about-printf-d-on-an-unsigned-int) We should use %d instead, or change the type of len to unsigned int. Using other C++ STL (like std::stringstream) is also good, I think. https://github.com/blue-oil/blueoil/blob/3510e3f12f4f4ef7f5c9b0c0c784e1cdc2a74a38/blueoil/converter/templates/include/npy.hpp#L104