Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
edalm opened this issue Oct 19, 2023 · 0 comments
Open

Comments

@edalm
Copy link

edalm commented Oct 19, 2023

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.

@edalm edalm changed the title Unused variable warning (maxDistance) warning: 'maxDistance' may be used uninitialized [-Wmaybe-uninitialized] Oct 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant