hust-diangroup / ns3-ai

Enable the interaction between ns-3 and popular frameworks using Python, which mean you can train and test your AI algorithms in ns-3 without changing any frameworks you are using now!
GNU General Public License v2.0
220 stars 80 forks source link

warning: 'maxDistance' may be used uninitialized [-Wmaybe-uninitialized] #103

Open edalm opened 10 months ago

edalm commented 10 months ago

When trying to compile the latest version of ns3-ai (main branch), the following warning is shown:

[57/102] Building CXX object contrib/ai/examples/multi-bss/CMakeFiles/ns3ai_multibss.dir/multi-bss.cc.o
In file included from /usr/include/c++/12/istream:39,
                 from /usr/include/c++/12/fstream:38,
                 from /home/edalm/development/ns-3/ns-3.40/cmake-cache/CMakeFiles/stdlib_pch_exec.dir/cmake_pch.hxx:9,
                 from <command-line>:
In member function ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>]’,
    inlined from ‘void PrintPythonPlotCSV(std::string)’ at /home/edu/development/ns-3/ns-3.40/contrib/ai/examples/multi-bss/multi-bss.cc:895:75:
/usr/include/c++/12/ostream:221:25: warning: ‘maxDistance’ may be used uninitialized [-Wmaybe-uninitialized]
  221 |       { return _M_insert(__f); }
      |                ~~~~~~~~~^~~~~
/home/edalm/development/ns-3/ns-3.40/contrib/ai/examples/multi-bss/multi-bss.cc: In function ‘void PrintPythonPlotCSV(std::string)’:
/home/edalm/development/ns-3/ns-3.40/contrib/ai/examples/multi-bss/multi-bss.cc:797:12: note: ‘maxDistance’ was declared here
  797 |     double maxDistance;
      |            ^~~~~~~~~~~

This warning can be solved by initializing the maxDistance variable when it's declared on line 797.