GDB printer testing uninitialized variables

Thomas Baumgart thb at net-bembel.de
Fri Jul 30 14:37:46 BST 2021


On Donnerstag, 29. Juli 2021 19:34:14 CEST Da Viper via Kde-finance-apps wrote:

> Hello there,  i am trying to test variables that has not been
> initialised for example
> if the break point is on line 10
> 
> ```
> 10 ....
> 11 .....
> 12 QChar achar;
> ```
> 
> and try to print the val of `achar`.
> the value of `achar` are not always consistent if it run, and
> sometimes depend on other variables before it.

Yes, because that is an invalid access. The object is not yet initialized.

> because of this i am not able to test  the values correctly.

You can only do so once past line 12 (when the ctor has been executed).
Anything else is an invalid testcase.

> should i drop the tests for uninitialised variables or is there a way
> for the variables to have a consistent values when debugged ?

Yes (first part) and no (second part).

-- 

Regards

Thomas Baumgart

https://www.signal.org/       Signal, the better WhatsApp
-------------------------------------------------------------
Real backups of your NAS can be found with the NSA
-------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 868 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-finance-apps/attachments/20210730/f322627d/attachment.sig>


More information about the Kde-finance-apps mailing list