What causes error " called on pointer returned from a mismatched allocation function"
-
wrote on 16 Aug 2021, 16:05 last edited by
In my program I'm seeing a few of the error below. There is no indication where in my program the error is, or what the problem is. It has something to do (I think) with using the wrong function to delete an object created with new. But I can't figure out anything beyond that.
Any ideas?
/opt/Qt/5.15.2/gcc_64/include/QtQml/qqmlprivate.h:166: warning: ‘static void QQmlPrivate::QQmlElement<T>::operator delete(void*, void*) [with T = GUIManager]’ called on pointer returned from a mismatched allocation function [-Wmismatched-new-delete] /opt/Qt/5.15.2/gcc_64/include/QtQml/qqmlprivate.h: In function ‘void QQmlPrivate::createInto(void*) [with T = GUIManager]’: /opt/Qt/5.15.2/gcc_64/include/QtQml/qqmlprivate.h:166:37: warning: ‘static void QQmlPrivate::QQmlElement<T>::operator delete(void*, void*) [with T = GUIManager]’ called on pointer returned from a mismatched allocation function [-Wmismatched-new-delete] 166 | void createInto(void *memory) { new (memory) QQmlElement<T>; } | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /opt/Qt/5.15.2/gcc_64/include/QtQml/qqmlprivate.h:166:37: note: returned from ‘void* operator new(std::size_t, void*)’
-
Hi,
You should add which version of gcc you are using.
-
I have the same problem when run Qt extended project example (GCC 11.1.0)
@ocgltd is your problem solved? -
wrote on 31 Jan 2022, 05:07 last edited by ChrisW67
It looks to me that something has allocated memory with operator new[] and used delete on it (or conversely allocated it using operator new and used delete[] on it). This is a warning not a fatal error.
Qt 5.15 reference versions on Linux are GCC 10 or lower. This looks like a warning (-Wmismatched-new-delete) that has become on by default under GCC 11.
-
It looks to me that something has allocated memory with operator new[] and used delete on it (or conversely allocated it using operator new and used delete[] on it). This is a warning not a fatal error.
Qt 5.15 reference versions on Linux are GCC 10 or lower. This looks like a warning (-Wmismatched-new-delete) that has become on by default under GCC 11.
wrote on 31 Jan 2022, 17:33 last edited byI'm using GCC 64 bit
I found a bug report about this, so I think it's a known error (to compensate for an MSVC issues). I am ignoring it and all seems to work (though I don't like such scary messages suggesting I'm going to free memory incorrectly)