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 Updated to NodeBB v4.3 + New Features

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.7k Views 2 Watching
  • 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.
  • ocgltdO Offline
    ocgltdO Offline
    ocgltd
    wrote on 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
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on 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

      ocgltdO 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        You should add which version of gcc you are using.

        ocgltdO Offline
        ocgltdO Offline
        ocgltd
        wrote on 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
        • zhmhZ Offline
          zhmhZ Offline
          zhmh
          wrote on last edited by
          #4

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

          ocgltdO 1 Reply Last reply
          0
          • zhmhZ zhmh

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

            ocgltdO Offline
            ocgltdO Offline
            ocgltd
            wrote on 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 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.

              ocgltdO 1 Reply Last reply
              0
              • C 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.

                ocgltdO Offline
                ocgltdO Offline
                ocgltd
                wrote on 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