GCC 12 will output an error if the wrong `delete` is used. Fixes #6930 (cherry picked from commit 57c736f1)