Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. SOLVED "value optimized out " C++ error

SOLVED "value optimized out " C++ error

Scheduled Pinned Locked Moved C / C++ / MFC
c++help
4 Posts 3 Posters 20 Views 1 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    SOLVED As suspected , passing parameters to object was incomplete and incorrect. Many thanks for all support received.

    L K Richard Andrew x64R 3 Replies Last reply
    0
    • L Lost User

      SOLVED As suspected , passing parameters to object was incomplete and incorrect. Many thanks for all support received.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      It is not clear, but I suspect the compiler has optimized it to something like:

      MainWindow_C_CODE_FORM *MWCCF_List = new MainWindow_C_CODE_FORM(nullptr, (QStringList){ " Process basic hcitool commands "," I/O hcitool "," DEBUG Trace " });

      assuming that QSL is not used anywhere else.

      1 Reply Last reply
      0
      • L Lost User

        SOLVED As suspected , passing parameters to object was incomplete and incorrect. Many thanks for all support received.

        K Offline
        K Offline
        k5054
        wrote on last edited by
        #3

        Warning messages out of context are not very helpful. We don't know for at fact that the messages you provided to us are anything to do with the supplied code. IMHO it seems highly unlikely that the value being optimized out is responsible for the possible memory leak. If the compiler can reason that it can optimize away a variable, it should know that no memory clean up is needed. But cleanup may be part of the the expected tasks of the programmer, and adding it in (if needed) might remove both warnings. Start by fixing the issue you have passing the QWidget correctly. There's no telling what doing it wrong might be doing internally. It sounds like a recipe for invoking undefined behavior. If the warnings persist after fixing the calling issue, then start by turning off optimization. If you're on Linux, you might also make sure that you're including debug symbols (-g flag). Depending on what "the tool" is, adding in debugging symbols might help narrow down the origin of the memory leak. Consult the documentation for your IDE (QT Creator?) on how you go about setting the optimization level, and turning on inclusion of debug symbols in the executable.

        Keep Calm and Carry On

        1 Reply Last reply
        0
        • L Lost User

          SOLVED As suspected , passing parameters to object was incomplete and incorrect. Many thanks for all support received.

          Richard Andrew x64R Offline
          Richard Andrew x64R Offline
          Richard Andrew x64
          wrote on last edited by
          #4

          This is just an educated guess on my part, and I'm not a C/C++ expert by any means. Maybe the compiler is telling you that it's discarding the copy of the QStringList that is being created when you pass by value. (Especially since the value is not being used inside the function, I think the compiler might be optimising it away and letting you know.)

          The difficult we do right away... ...the impossible takes slightly longer.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups