Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QVector instance passed into a method by reference is inaccessible to the debugger



  • I pass an instance of QVector into my method

    const QVector<quint32>& vec
    

    but when I hover above the variable, the debugger says

    vec <not accessible>

    and if I add an expression evaluator, it does not evaluate.
    I am in QT Creator 4.7.2 under QT 5.11.3 in Windows with Win SDK 10 CDB for a debugger.


  • Moderators

    Probably got optimized away or function got inlined. Are you running a Release config by any chance?



  • I do not believe it is possible to debug a release config. At least it does not occur to me to try. I am in a debug config.
    How can a compiler optimize away an instance of a class?



  • @In-Fo
    We could have a long discussion about how & why compilers can indeed optimize this and many other statements away. (Even in debug: I recall being surprised and having a conversation about this a long time ago.)

    In terms of practical, from where you are now. You could fiddle with code to try to introduce another variable or statement to resurrect your debugging ability on this symbol. But I'm just thinking: since it's a reference parameter, does your CDB allow you to go up to the calling frame simply and display the vector passed in there? Which may suffice for your debugging experience, if this is not a huge issue.


  • Moderators

    I do not believe it is possible to debug a release config

    You better believe it :) release configs are just optimized. They can have debug info just the same as Debug builds.

    How can a compiler optimize away an instance of a class?

    Easily ;) CPUs don't have a notion of classes. It's all just bytes to them.

    It sounds a bit weird in a Debug build though. Could you provide a minimal compilable example of that problem?



  • I am trying plain old pointers and none of the buf[0] kind of inspectors work.


Log in to reply