Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. What causes error " called on pointer returned from a mismatched allocation function"
Forum Update on Monday, May 27th 2025

What causes error " called on pointer returned from a mismatched allocation function"

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 4.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    ocgltd
    wrote on 16 Aug 2021, 16:05 last edited by
    #1

    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*)’
    
    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 16 Aug 2021, 18:20 last edited by
      #2

      Hi,

      You should add which version of gcc you are using.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      O 1 Reply Last reply 17 Aug 2021, 21:20
      0
      • S SGaist
        16 Aug 2021, 18:20

        Hi,

        You should add which version of gcc you are using.

        O Offline
        O Offline
        ocgltd
        wrote on 17 Aug 2021, 21:20 last edited by
        #3

        @SGaist My compiler shows:

        gcc version 11.1.1 20210531 (Red Hat 11.1.1-3) (GCC)
        
        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          zhmh
          wrote on 13 Sept 2021, 05:57 last edited by
          #4

          I have the same problem when run Qt extended project example (GCC 11.1.0)
          @ocgltd is your problem solved?

          O 1 Reply Last reply 30 Jan 2022, 20:19
          0
          • Z zhmh
            13 Sept 2021, 05:57

            I have the same problem when run Qt extended project example (GCC 11.1.0)
            @ocgltd is your problem solved?

            O Offline
            O Offline
            ocgltd
            wrote on 30 Jan 2022, 20:19 last edited by
            #5

            @zhmh No...still scratching my head on this one

            1 Reply Last reply
            0
            • C Offline
              C Offline
              ChrisW67
              wrote on 31 Jan 2022, 05:07 last edited by ChrisW67
              #6

              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.

              O 1 Reply Last reply 31 Jan 2022, 17:33
              0
              • C ChrisW67
                31 Jan 2022, 05:07

                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.

                O Offline
                O Offline
                ocgltd
                wrote on 31 Jan 2022, 17:33 last edited by
                #7

                I'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)

                1 Reply Last reply
                1

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved