New dangling reference warning in develop

Open
#447 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp
Domain
testing-qa

Research direction

Start with boost/test/impl/framework.ipp at lines 403 and 1000, then inspect runtime_config::get and nearby tests. Confirm the warning with GCC 13 on MinGW and verify that the dangling-reference warnings no longer appear without changing the intended filter or logger behavior.

Written by the indexing model from the issue text.

Description

After updating to develop I see:

gcc.compile.c++ ..\..\..\bin.v2\libs\test\build\gcc-13\debug\x86_64\cxxstd-17-gnu\link-static\pch-off\threadapi-win32\threading-multi\visibility-hidden\framework.o
In file included from D:/data/boost/boost/libs/test/src/framework.cpp:16:
..\..\../boost/test/impl/framework.ipp: In function 'bool boost::unit_test::framework::impl::parse_filters(boost::unit_test::test_unit_id, boost::unit_test::test_unit_id_list&, boost::unit_test::test_unit_id_list&)':
..\..\../boost/test/impl/framework.ipp:403:37: warning: possibly dangling reference to a temporary [-Wdangling-reference]
403 |     std::vector<std::string> const& filters = runtime_config::get<std::vector<std::string> >( runtime_config::btrt_run_filters );
    |                                     ^~~~~~~                                                                     ..\..\../boost/test/impl/framework.ipp:403:93: note: the temporary was destroyed at the end of the full expression 'boost::unit_test::runtime_config::get<std::vector<std::__cxx11::basic_string<char> > >(boost::unit_test::basic_cstring<const char>(boost::unit_test::runtime_config::btrt_run_filters))'
403 |     std::vector<std::string> const& filters = runtime_config::get<std::vector<std::string> >( runtime_config::btrt_run_filters );
    |                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
..\..\../boost/test/impl/framework.ipp: In function 'void boost::unit_test::framework::impl::setup_loggers()':
..\..\../boost/test/impl/framework.ipp:1000:45: warning: possibly dangling reference to a temporary [-Wdangling-reference]
1000 |             const std::vector<std::string>& v_output_format = runtime_config::get< std::vector<std::string> >( runtime_config::btrt_combined_logger ) ;
     |                                             ^~~~~~~~~~~~~~~
..\..\../boost/test/impl/framework.ipp:1000:110: note: the temporary was destroyed at the end of the full expression 'boost::unit_test::runtime_config::get<std::vector<std::__cxx11::basic_string<char> > >(boost::unit_test::basic_cstring<const char>(boost::unit_test::runtime_config::btrt_combined_logger))'
1000 |             const std::vector<std::string>& v_output_format = runtime_config::get< std::vector<std::string> >( runtime_config::btrt_combined_logger ) ;
     |                                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~

With gcc-13 Mingw.

Dominant language
C++
Stars
213
Forks
149
Avg merge
18h 17m
Merged PRs (30d)
2

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/test

All issues in boostorg/test

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.