eloquentarduino / EloquentTinyML

Eloquent interface to Tensorflow Lite for Microcontrollers
301 stars 57 forks source link

warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] when compiling #49

Closed m4nzm333 closed 10 months ago

m4nzm333 commented 2 years ago

Hi dev,

I'm trying to use TinyML fo my project. And when I compile my code , it gives me error :

D:\USERDATA\Documents\Arduino\libraries\EloquentTinyML\src\eloquent_tinyml\tensorflow\esp32\tensorflow\lite\experimental\micro\micro_allocator.cpp:101:40: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
if (buffer == nullptr || input_index < 0 ||
~~~~~~~~~^~~
D:\USERDATA\Documents\Arduino\libraries\EloquentTinyML\src\eloquent_tinyml\tensorflow\esp32\tensorflow\lite\experimental\micro\micro_allocator.cpp: In member function 'TfLiteStatus tflite::MicroAllocator::AllocateNodeAndRegistrations(const tflite::OpResolver&, tflite::NodeAndRegistration**)':
D:\USERDATA\Documents\Arduino\libraries\EloquentTinyML\src\eloquent_tinyml\tensorflow\esp32\tensorflow\lite\experimental\micro\micro_allocator.cpp:137:15: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
if (index < 0 || index >= opcodes->size()) {
~~~~~~^~~
D:\USERDATA\Documents\Arduino\libraries\EloquentTinyML\src\eloquent_tinyml\tensorflow\esp32\tensorflow\lite\experimental\micro\micro_allocator.cpp: In member function 'TfLiteStatus tflite::MicroAllocator::InitializeRuntimeTensor(const tflite::Tensor&, const flatbuffers::Vector<flatbuffers::Offset<tflite::Buffer> >*, tflite::ErrorReporter*, TfLiteTensor*, uint8_t*)':
D:\USERDATA\Documents\Arduino\libraries\EloquentTinyML\src\eloquent_tinyml\tensorflow\esp32\tensorflow\lite\experimental\micro\micro_allocator.cpp:400:18: error: unused variable 'array_size' [-Werror=unused-variable]
if (size_t array_size = array->size()) {
^~~~~~~~~~
D:\USERDATA\Documents\Arduino\libraries\EloquentTinyML\src\eloquent_tinyml\tensorflow\esp32\tensorflow\lite\experimental\micro\micro_interpreter.cpp: In member function 'TfLiteTensor* tflite::MicroInterpreter::input(size_t)':
D:\USERDATA\Documents\Arduino\libraries\EloquentTinyML\src\eloquent_tinyml\tensorflow\esp32\tensorflow\lite\experimental\micro\micro_interpreter.cpp:231:14: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
if ((index < 0) || (index >= length)) {
~~~~~~^~~
D:\USERDATA\Documents\Arduino\libraries\EloquentTinyML\src\eloquent_tinyml\tensorflow\esp32\tensorflow\lite\experimental\micro\micro_interpreter.cpp: In member function 'TfLiteTensor* tflite::MicroInterpreter::output(size_t)':
D:\USERDATA\Documents\Arduino\libraries\EloquentTinyML\src\eloquent_tinyml\tensorflow\esp32\tensorflow\lite\experimental\micro\micro_interpreter.cpp:242:14: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
if ((index < 0) || (index >= outputs->size())) {
~~~~~~^~~
D:\USERDATA\Documents\Arduino\libraries\EloquentTinyML\src\eloquent_tinyml\tensorflow\esp32\tensorflow\lite\experimental\micro\micro_interpreter.cpp: In member function 'TfLiteTensor* tflite::MicroInterpreter::tensor(size_t)':
D:\USERDATA\Documents\Arduino\libraries\EloquentTinyML\src\eloquent_tinyml\tensorflow\esp32\tensorflow\lite\experimental\micro\micro_interpreter.cpp:252:14: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
if ((index < 0) || (index >= tensors_size())) {
~~~~~~^~~

My environment is OS : Windows 10 10.0.19044.2130 (21H2) ArduinoIDE v1.8.19 Board ESP32-DEVKIT-V1 TinyML 2.4.4

It may sound weird because the current tag here is 2.4.0, but I found that 2.4.4 is latest version at my Library Manager.

Thank you

eloquentarduino commented 2 years ago

It looks like a warning, not an error. Go to Arduino > Preferences and set "Compiler warnings" to "few". You probably have "All".