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. After using toStdString, the string exhibited abnormal behavior.
Forum Updated to NodeBB v4.3 + New Features

After using toStdString, the string exhibited abnormal behavior.

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 138 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.
  • J Offline
    J Offline
    John Van
    wrote last edited by
    #1

    The size has changed from 3 to 261993005056, and the Qt version is 5.15.2.
    749a9af1-4a7f-4c67-a1dd-72778307f88e-image.png

    JonBJ 1 Reply Last reply
    0
    • J John Van

      The size has changed from 3 to 261993005056, and the Qt version is 5.15.2.
      749a9af1-4a7f-4c67-a1dd-72778307f88e-image.png

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote last edited by
      #2

      @John-Van
      My first thought is that you cannot guarantee the code generated has even written anything into your s2 variable. It's just a local variable and never referenced after dataStore[r] = s2;. The code generated might implement this as dataStore[r] = s1.toStdString();.

      Put a breakpoint on those lines and step through them. Does anything (the content, not just the size) in s2 even change? Put in a qDebug() statement to examine what is in s2, does that output something different? Pass s2 as a parameter to some other function and examine what it passes there, is that correct or wrong?

      mzimmersM 1 Reply Last reply
      0
      • Kent-DorfmanK Offline
        Kent-DorfmanK Offline
        Kent-Dorfman
        wrote last edited by
        #3

        @JonB interesting point...making s2 volatile should hopefully tell the compiler to not optimize it out, thus allowing inspection of it's attributes. Hey! a use for poor underappreciated "volatile"!

        1 Reply Last reply
        0
        • JonBJ JonB

          @John-Van
          My first thought is that you cannot guarantee the code generated has even written anything into your s2 variable. It's just a local variable and never referenced after dataStore[r] = s2;. The code generated might implement this as dataStore[r] = s1.toStdString();.

          Put a breakpoint on those lines and step through them. Does anything (the content, not just the size) in s2 even change? Put in a qDebug() statement to examine what is in s2, does that output something different? Pass s2 as a parameter to some other function and examine what it passes there, is that correct or wrong?

          mzimmersM Offline
          mzimmersM Offline
          mzimmers
          wrote last edited by mzimmers
          #4

          @JonB yeah, I've seen this before. If I'm reading this case correctly, the variable s2 is no longer needed by line 115, and has either been trashed or no longer properly maintained by the debugger.

          1 Reply Last reply
          0

          • Login

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