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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Here is a reduced testcase without any std::map or otherwise:
```
struct matrix_t
{
  int* count;

  matrix_t() :
    count(new int(1)) {}

  matrix_t(const matrix_t& p) :
    count(p.count) { ++*count; }

  ~matrix_t() { if (--*count == 0) { delete count;  } }
};

void f();
void cache1(void)
{
  matrix_t wftable;
  matrix_t wftable1(wftable);
  f();
}

```
basically what is going on is GCC cannot figure out the load from the count in
the first deconstructor will be greater than 1. GCC didn't inline the
deconstructor on the unwinding from exception which is causing GCC to think
count escapes and is read by f; the original case there is similar non-inlining
which is causing a similar issue.

The warning is a false positive but it is hard to prove unless you understand
the IR and such.

Reply via email to