Derived class members are outofscope when debugging C++

    • Derived class members are outofscope when debugging C++

      Hello,


      We are having a hard time debugging our code base which is primarily C++ based. Class members in derived classes are shown as "outofscope" in some cases. In the following example, a.var1, a.var2, b.var1 and b.var2 are "outofscope". If A class is not instatiated, b.var1 and b.var2 are visible as expected which is strange.

      [img]https://forum.segger.com/index.php/Attachment/6226/[/img]

      C Source Code: AClass.h

      1. #ifndef ACLASS_H
      2. #define ACLASS_H
      3. class AParent
      4. {
      5. public:
      6. int var2;
      7. };
      8. class A : public AParent
      9. {
      10. public:
      11. int var1;
      12. };
      13. #endif
      Display All




      C Source Code: main.cpp

      1. #include "AClass.h"
      2. class BParent
      3. {
      4. public:
      5. int var2;
      6. };
      7. class B :public BParent
      8. {
      9. public:
      10. int var1;
      11. };
      12. //If A class is not instantiated, b.var1 and b.var2 are NOT out of scope
      13. A a;
      14. B b;
      15. int main(int, char *[])
      16. {
      17. while (1)
      18. {
      19. b.var1++;
      20. b.var2++;
      21. }
      22. }
      Display All


      The issue is not present if the code is compiled with Segger Embedded Studio


      Stm32F439
      Ozone 3.38f
      -O0
      GCC toolchain 12.2 (same issue on 14.2)
      developer.arm.com/-/media/File…7E047708C49F9E16D17A85311

      Related issue:

      [ABANDONED] Problem with C++ and
      Images
      • global_data_outofscope.png

        12.9 kB, 1,094×222, viewed 64 times
      Files
      • outofscope.zip

        (25.64 kB, downloaded 104 times, last: )