https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54202
Giuseppe D'Angelo <dangelog at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dangelog at gmail dot com --- Comment #8 from Giuseppe D'Angelo <dangelog at gmail dot com> --- The original testcase by Thiago still fails with GCC 11. Unfortunately, GCC 11 decided to turn -Wfree-nonheap-object on by default (!), resulting in false positives for Qt users (containers in Qt use this pattern). For instance https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/tools/qlinkedlist.h?h=5.15 struct QT_DEPRECATED_VERSION_5_15 QLinkedListData { QLinkedListData *n, *p; QtPrivate::RefCount ref; // set to -1 for shared_null int size; uint sharable : 1; Q_CORE_EXPORT static const QLinkedListData shared_null; }; template <typename T> inline QLinkedList<T>::~QLinkedList() { if (!d->ref.deref()) freeData(d); // never called on shared_null because of the check } template <typename T> void QLinkedList<T>::freeData(QLinkedListData *x) { // ... delete x; // -Wfree-nonheap-object here }