Skip to content

CheckerGccPlugins: Fix a deletion issue seen with gcc14.

In a code fragment like

void foo (const C* p)
{
  delete p;
}

gcc14 can insert a temporary SSA variable before the delete, the type of which will be a non-const pointer. This can then lead to a warning about discarded const. But that doesn't matter, since all we do with the pointer is a deletion.

Try to detect this case: if we have a discarded const, but the target is used only for deletion, then don't warn.

Merge request reports