2

I'm running iwyu over my code base, and there are a few files where it insists I add

#include <cxxabi.h>  // for __forced_unwind

I was able to ablate code and find that it seems related to cv.wait(mu).

Specifically, the no predicate version.

If I remove cv.wait(mu), iwyu no longer suggests cxxabi.h.

What is this __forced_unwind function, why is iwyu recommending it, and can this safely be ignored?

Minimal test case:

// foo.cpp

#include <condition_variable>
#include <mutex>

void foo(std::condition_variable_any* cv, std::mutex* mu) {
  cv->wait(*mu);
}
src/foo.cpp should add these lines:
#include <cxxabi.h>            // for __forced_unwind

src/foo.cpp should remove these lines:

The full include-list for src/foo.cpp:
#include <cxxabi.h>            // for __forced_unwind
#include <condition_variable>  // for condition_variable_any
#include <mutex>               // for mutex
---
user100046
  • 422
  • 4
  • 11
  • Seems like the standard header in libstdc++ has this covered by including ``: https://github.com/gcc-mirror/gcc/blob/master/libstdc++-v3/include/std/condition_variable So my guess us that iwyu is just not aware of that? –  May 04 '20 at 21:13
  • @Frank Thanks for pointing that out. I added `{ include: [ "", private, "", public ] },` to the imp file and that took care of it for now. Not sure whether I want to include `` whenever some c++ header uses `__forced_unwind`, but I'll cross that bridge later. If you make a top-level answer, I'll accept it. – user100046 May 04 '20 at 23:27
  • In my case it was `` which caused this, so I added `{ include: [ "", private, "", public ] },` – Flow Jan 13 '21 at 11:44

0 Answers0