RigsOfRods / rigs-of-rods

Main development repository for Rigs of Rods soft-body physics simulator
https://www.rigsofrods.org
GNU General Public License v3.0
1.01k stars 175 forks source link

Fixed gcc warning #2910

Closed tritonas00 closed 11 months ago

tritonas00 commented 2 years ago

Lately gcc complains:

[ 41%] Building CXX object source/main/CMakeFiles/RoR.dir/physics/flex/FlexMeshWheel.cpp.o
/home/babis/Downloads/ror-dependencies/rigs-of-rods/source/main/physics/flex/FlexMeshWheel.cpp: In constructor ‘RoR::FlexMeshWheel::FlexMeshWheel(Ogre::Entity*, RoR::GfxActor*, int, int, int, int, const std::string&, const std::string&, float, bool)’:
/home/babis/Downloads/ror-dependencies/rigs-of-rods/source/main/physics/flex/FlexMeshWheel.cpp:86:38: warning: argument 1 value ‘1844674407370955155 ’ exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]
   86 |     m_indices=(unsigned short*)malloc(m_index_count*sizeof(unsigned short));
      |                                ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/12.1.0/cstdlib:75,
                 from /usr/include/c++/12.1.0/ext/string_conversions.h:41,
                 from /usr/include/c++/12.1.0/bits/basic_string.h:3960,
                 from /usr/include/c++/12.1.0/string:53,
                 from /home/babis/Downloads/ror-dependencies/rigs-of-rods/source/main/phc.h:25,
                 from /home/babis/Downloads/ror-dependencies/rigs-of-rods/source/main/CMakeFiles/RoR.dir/cmake_pch.hxx:5,
                 from <command-line>:
/usr/include/stdlib.h:540:14: note: in a call to allocation function ‘void* malloc(size_t)’ declared here
  540 | extern void *malloc (size_t __size) __THROW __attribute_malloc__
      |              ^~~~~~

I don't know if this is the correct way to fix it but it suppress the warning.

ohlidalp commented 11 months ago

I'm sure this isn't true anymore.

tritonas00 commented 11 months ago

I'm sure this isn't true anymore.

The warning still appears, on Lunix, gcc

ohlidalp commented 11 months ago

OK, let me try to stuff vector<> in there...

ohlidalp commented 11 months ago

@tritonas00 Try again please. GitHub won't let me request your review since it's your PR 😆

tritonas00 commented 11 months ago

No warnings :+1: