LostRuins / koboldcpp

Run GGUF models easily with a KoboldAI UI. One File. Zero Install.
https://github.com/lostruins/koboldcpp
GNU Affero General Public License v3.0
5.35k stars 364 forks source link

C++ problems: use of uninitialized values, expressions are unused, comparisons always true, etc. #1062

Open yurivict opened 3 months ago

yurivict commented 3 months ago

Describe the Issue

otherarch/sdcpp/tae.hpp:194:17: warning: field 'decode_only' is uninitialized when used here [-Wuninitialized]
  194 |           taesd(decode_only),
      |                 ^
In file included from otherarch/sdcpp/sdtype_adapter.cpp:19:
In file included from ./otherarch/sdcpp/thirdparty/zip.c:39:
./otherarch/sdcpp/thirdparty/miniz.h:4988:9: warning: Using fopen, ftello, fseeko, stat() etc. path for file I/O - this path may not support large files. [-W#pragma-messages]
 4988 | #pragma message(                                                               \
      |         ^
In file included from otherarch/sdcpp/sdtype_adapter.cpp:34:
./otherarch/sdcpp/thirdparty/stb_image_resize.h:760:31: warning: expression result unused [-Wunused-value]
  760 |     STBIR__DEBUG_ASSERT(scale <= 1);
      |                         ~~~~~ ^  ~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:778:31: warning: expression result unused [-Wunused-value]
  778 |     STBIR__DEBUG_ASSERT(scale <= 1);
      |                         ~~~~~ ^  ~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1041:56: warning: expression result unused [-Wunused-value]
 1041 |     STBIR__DEBUG_ASSERT(in_last_pixel - in_first_pixel <= (int)ceil(stbir__filter_info_table[filter].support(1/scale) * 2)); // Taken directly from stbir__get_coefficient_width() which we can't call because we don't know if we're horizontal or vertical.
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1046:41: warning: expression result unused [-Wunused-value]
 1046 |     STBIR__DEBUG_ASSERT(contributor->n1 >= contributor->n0);
      |                         ~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1064:128: warning: expression result unused [-Wunused-value]
 1064 |     STBIR__DEBUG_ASSERT(stbir__filter_info_table[filter].kernel((float)(in_last_pixel + 1) + 0.5f - in_center_of_out, 1/scale) == 0);
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1066:38: warning: expression result unused [-Wunused-value]
 1066 |     STBIR__DEBUG_ASSERT(total_filter > 0.9);
      |                         ~~~~~~~~~~~~ ^ ~~~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1067:38: warning: expression result unused [-Wunused-value]
 1067 |     STBIR__DEBUG_ASSERT(total_filter < 1.1f); // Make sure it's not way off.
      |                         ~~~~~~~~~~~~ ^ ~~~~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1089:59: warning: expression result unused [-Wunused-value]
 1089 |      STBIR__DEBUG_ASSERT(out_last_pixel - out_first_pixel <= (int)ceil(stbir__filter_info_table[filter].support(scale_ratio) * 2)); // Taken directly from stbir__get_coefficient_width() which we can't call because we don't know if we're horizontal or vertical.
      |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1094:41: warning: expression result unused [-Wunused-value]
 1094 |     STBIR__DEBUG_ASSERT(contributor->n1 >= contributor->n0);
      |                         ~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1103:133: warning: expression result unused [-Wunused-value]
 1103 |     STBIR__DEBUG_ASSERT(stbir__filter_info_table[filter].kernel((float)(out_last_pixel + 1) + 0.5f - out_center_of_in, scale_ratio) == 0);
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1138:35: warning: expression result unused [-Wunused-value]
 1138 |         STBIR__DEBUG_ASSERT(total > 0.9f);
      |                             ~~~~~ ^ ~~~~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1139:35: warning: expression result unused [-Wunused-value]
 1139 |         STBIR__DEBUG_ASSERT(total < 1.1f);
      |                             ~~~~~ ^ ~~~~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1427:47: warning: expression result unused [-Wunused-value]
 1427 |         STBIR__DEBUG_ASSERT(ring_buffer_index != stbir_info->ring_buffer_begin_index);
      |                             ~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1459:32: warning: expression result unused [-Wunused-value]
 1459 |         STBIR__DEBUG_ASSERT(n1 >= n0);
      |                             ~~ ^  ~~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1460:32: warning: expression result unused [-Wunused-value]
 1460 |         STBIR__DEBUG_ASSERT(n0 >= -stbir_info->horizontal_filter_pixel_margin);
      |                             ~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1461:32: warning: expression result unused [-Wunused-value]
 1461 |         STBIR__DEBUG_ASSERT(n1 >= -stbir_info->horizontal_filter_pixel_margin);
      |                             ~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1462:32: warning: expression result unused [-Wunused-value]
 1462 |         STBIR__DEBUG_ASSERT(n0 < stbir_info->input_w + stbir_info->horizontal_filter_pixel_margin);
      |                             ~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1463:32: warning: expression result unused [-Wunused-value]
 1463 |         STBIR__DEBUG_ASSERT(n1 < stbir_info->input_w + stbir_info->horizontal_filter_pixel_margin);
      |                             ~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1471:53: warning: expression result unused [-Wunused-value]
 1471 |                     STBIR__DEBUG_ASSERT(coefficient != 0);
      |                                         ~~~~~~~~~~~ ^  ~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1480:53: warning: expression result unused [-Wunused-value]
 1480 |                     STBIR__DEBUG_ASSERT(coefficient != 0);
      |                                         ~~~~~~~~~~~ ^  ~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1490:53: warning: expression result unused [-Wunused-value]
 1490 |                     STBIR__DEBUG_ASSERT(coefficient != 0);
      |                                         ~~~~~~~~~~~ ^  ~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1501:53: warning: expression result unused [-Wunused-value]
 1501 |                     STBIR__DEBUG_ASSERT(coefficient != 0);
      |                                         ~~~~~~~~~~~ ^  ~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1514:53: warning: expression result unused [-Wunused-value]
 1514 |                     STBIR__DEBUG_ASSERT(coefficient != 0);
      |                                         ~~~~~~~~~~~ ^  ~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1537:25: warning: expression result unused [-Wunused-value]
 1537 |     STBIR__DEBUG_ASSERT(!stbir__use_width_upsampling(stbir_info));
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1555:53: warning: expression result unused [-Wunused-value]
 1555 |                     STBIR__DEBUG_ASSERT(coefficient != 0);
      |                                         ~~~~~~~~~~~ ^  ~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1576:53: warning: expression result unused [-Wunused-value]
 1576 |                     STBIR__DEBUG_ASSERT(coefficient != 0);
      |                                         ~~~~~~~~~~~ ^  ~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1598:53: warning: expression result unused [-Wunused-value]
 1598 |                     STBIR__DEBUG_ASSERT(coefficient != 0);
      |                                         ~~~~~~~~~~~ ^  ~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1621:53: warning: expression result unused [-Wunused-value]
 1621 |                     STBIR__DEBUG_ASSERT(coefficient != 0);
      |                                         ~~~~~~~~~~~ ^  ~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:1646:53: warning: expression result unused [-Wunused-value]
 1646 |                     STBIR__DEBUG_ASSERT(coefficient != 0);
      |                                         ~~~~~~~~~~~ ^  ~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:2005:25: warning: expression result unused [-Wunused-value]
 2005 |     STBIR__DEBUG_ASSERT(!stbir__use_height_upsampling(stbir_info));
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:2079:66: warning: expression result unused [-Wunused-value]
 2079 |         STBIR__DEBUG_ASSERT(in_last_scanline - in_first_scanline <= stbir_info->vertical_filter_pixel_width);
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:2171:25: warning: expression result unused [-Wunused-value]
 2171 |     STBIR__DEBUG_ASSERT(!stbir__use_height_upsampling(stbir_info));
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:2180:68: warning: expression result unused [-Wunused-value]
 2180 |         STBIR__DEBUG_ASSERT(out_last_scanline - out_first_scanline <= stbir_info->vertical_filter_pixel_width);
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:2382:92: warning: expression result unused [-Wunused-value]
 2382 |         STBIR__DEBUG_ASSERT((size_t)STBIR__NEXT_MEMPTR(info->encode_buffer, unsigned char) == (size_t)tempmem + tempmem_size_in_bytes);
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./otherarch/sdcpp/thirdparty/stb_image_resize.h:2390:90: warning: expression result unused [-Wunused-value]
 2390 |         STBIR__DEBUG_ASSERT((size_t)STBIR__NEXT_MEMPTR(info->ring_buffer, unsigned char) == (size_t)tempmem + tempmem_size_in_bytes);
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
otherarch/sdcpp/sdtype_adapter.cpp:267:73: warning: result of comparison of constant 244 with expression of type 'char' is always true [-Wtautological-constant-out-of-range-compare]
  267 |         if (static_cast<unsigned char>(ch) <= 0x7F || (ch >= 0xC2 && ch <= 0xF4)) {
      |                                                                      ~~ ^  ~~~~
otherarch/sdcpp/sdtype_adapter.cpp:267:59: warning: result of comparison of constant 194 with expression of type 'char' is always false [-Wtautological-constant-out-of-range-compare]
  267 |         if (static_cast<unsigned char>(ch) <= 0x7F || (ch >= 0xC2 && ch <= 0xF4)) {
      |                                                        ~~ ^  ~~~~
39 warnings generated.

Additional Information: Version: 1.72 clang-18

LostRuins commented 3 months ago

These come from the stb_image_resize external library. They can be safely ignored.