https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82481

            Bug ID: 82481
           Summary: dangling reference in mutex:693
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: heinzisoft at web dot de
  Target Milestone: ---

Building the following minimal example with libstdc++ 7.0.1 using clang-tidy
4.0.0 on Ubuntu 17.04:

main.cpp:

  #include <future>

  int main() {
    std::promise<int> p;
    p.set_value(3);
  }

Build command:

   $ clang-tidy main.cpp -extra-arg=-std=c++14

Output:

    Running without flags.
    1 warning generated.
   
/usr/lib/gcc/x86_64-linux-gnu/7.0.1/../../../../include/c++/7.0.1/mutex:693:5:
warning: Address of stack memory associated with local variable '__callable' is
still referred to by the global variable '__once_callable' upon returning to
the caller.  This will be a dangling reference
[clang-analyzer-core.StackAddressEscape]
        }
        ^
    /home/user/main.cpp:5:3: note: Calling 'promise::set_value'
      p.set_value(3);
      ^
   
/usr/lib/gcc/x86_64-linux-gnu/7.0.1/../../../../include/c++/7.0.1/future:1094:9:
note: Calling '_State_baseV2::_M_set_result'
          { _M_future->_M_set_result(_State::__setter(this, std::move(__r))); }
            ^
   
/usr/lib/gcc/x86_64-linux-gnu/7.0.1/../../../../include/c++/7.0.1/future:401:2:
note: Calling 'call_once'
            call_once(_M_once, &_State_baseV2::_M_do_set, this,
            ^
   
/usr/lib/gcc/x86_64-linux-gnu/7.0.1/../../../../include/c++/7.0.1/mutex:691:11:
note: Assuming '__e' is 0
          if (__e)
              ^
   
/usr/lib/gcc/x86_64-linux-gnu/7.0.1/../../../../include/c++/7.0.1/mutex:691:7:
note: Taking false branch
          if (__e)
          ^
   
/usr/lib/gcc/x86_64-linux-gnu/7.0.1/../../../../include/c++/7.0.1/mutex:693:5:
note: Address of stack memory associated with local variable '__callable' is
still referred to by the global variable '__once_callable' upon returning to
the caller.  This will be a dangling reference
        }

Reply via email to