cfillion / reapack

📦 Package manager for REAPER
https://reapack.com
GNU Lesser General Public License v3.0
316 stars 23 forks source link

Unsigned to signed problem #85

Closed noisecode3 closed 2 months ago

noisecode3 commented 2 months ago

You have int conversations that can lead to crash, that would be funny if someone hit this.. kind of low priority bug It should have used size_t somewhere. For uint32_t or uint16_t you would need I guess you don't like that. But a size_t is really a overkill... I guess I can fix this but don't want to right now, lol.

In member function ‘__ct ’,
    inlined from ‘make_unique’ at /usr/include/c++/14.1.0/bits/unique_ptr.h:1076:30,
    inlined from ‘createRow.constprop’ at /home/noisecode3/reapack/src/listview.cpp:97:51:
/home/noisecode3/reapack/src/listview.cpp:726:55: warning: argument 1 value ‘18446744073709551615’ exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]
  726 |   m_list(list), m_cells(new Cell[m_list->columnCount()])
      |                                                       ^
/usr/include/c++/14.1.0/new: In member function ‘createRow.constprop’:
/usr/include/c++/14.1.0/new:133:26: note: in a call to allocation function ‘operator new []’ declared here
  133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
      |                          ^
In member function ‘__ct ’,
    inlined from ‘make_unique’ at /usr/include/c++/14.1.0/bits/unique_ptr.h:1076:30,
    inlined from ‘createRow’ at /home/noisecode3/reapack/src/listview.cpp:97:51:
/home/noisecode3/reapack/src/listview.cpp:726:55: warning: argument 1 value ‘18446744073709551615’ exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]
  726 |   m_list(list), m_cells(new Cell[m_list->columnCount()])
      |                                                       ^
/usr/include/c++/14.1.0/new: In member function ‘createRow’:
/usr/include/c++/14.1.0/new:133:26: note: in a call to allocation function ‘operator new []’ declared here
  133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
      |                          ^

Microsoft documentation..

LLONG_MIN   Minimum value for a variable of type long long  -9223372036854775808
LLONG_MAX   Maximum value for a variable of type long long  9223372036854775807
ULLONG_MAX  Maximum value for a variable of type unsigned long long     18446744073709551615 (0xffffffffffffffff)
cfillion commented 2 months ago

Ah yeah, that warning only happens in release builds (LTO enabled). columnCount returns a size_t (std::vector::size) truncated to an int, but that size_t itself originates from an int (Win32's listbox API). In any cases it's a false positive since there are never going to be less than 0 or more than INT_MAX columns.