www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Same code different behaviour in debug & release mode?

reply =?utf-8?Q?Robert_M._M=C3=BCnch?= <robert.muench saphirion.com> writes:
I have the following code I compile in release mode but with 
"debugInfo" bulildOptions in my dub.json:

gob root = win.layout_root = new gob();

After executing this code line I see this in the debugger:


Name
Wert
Typ
◢
root
0x000000f17deff760 {node=0x00007ff629fb0000 {__guard_fids_table} {}, 
container=false, level=0, ax0=-2.7520788e+14, ...}
gui.gob

▶ __vfptr
0x0000000000000000
void*[36]*

node
0x00007ff629fb0000 {__guard_fids_table} {}
yoga.yoga.YGNode*

container
false
bool

level
0
int

ax0
-2.7520788e+14
float

ay0
7.4268819e-43
float

fill
true
bool

▶ id
""...
string
◢
win.layout_root
0x00000212d90481c0 {node=0x00000212d995eb90 {}, container=false, 
level=0, ax0=0, ay0=0, fill=false, id=""}
gui.gob

▶ __vfptr
0x00007ff62a4bd410 {_D3gui3gob6__vtblZ} {[0x00007ff62a4bd350 
{_D3gui3gob7__ClassZ}, 0x00007ff62a12c6c6 
{_D6object6Object8toStringMFZAya}, ...]}
void*[36]*

node
0x00000212d995eb90 {}
yoga.yoga.YGNode*

container
false
bool

level
0
int

ax0
0
float

ay0
0
float

fill
false
bool

id
""
string

I'm wondering why the root and win.layout_root values are not the same? 
What's happening here? I thought that root is a class reference which 
uses the same data as win.layout_root.

When I compile in debug mode and run the same code, the values are the same.

-- 
Robert M. Münch
http://www.saphirion.com
smarter | better | faster
May 19 2019
parent reply =?utf-8?Q?Robert_M._M=C3=BCnch?= <robert.muench saphirion.com> writes:
On 2019-05-19 16:11:19 +0000, Robert M. Münch said:

 I'm wondering why the root and win.layout_root values are not the same? 
 What's happening here? I thought that root is a class reference which 
 uses the same data as win.layout_root.
 
 
 When I compile in debug mode and run the same code, the values are the same.
It seems that the debugger has quite some problem when the code was compiled with optimization and debug-information. When avoiding optimization, things seems to work. -- Robert M. Münch http://www.saphirion.com smarter | better | faster
May 19 2019
parent Era Scarecrow <rtcvb32 yahoo.com> writes:
On Sunday, 19 May 2019 at 17:55:10 UTC, Robert M. Münch wrote:
 It seems that the debugger has quite some problem when the code 
 was compiled with optimization and debug-information.
I remember having similar problems in a C program years ago, ended up just releasing the code unoptimized and with asserts still in place. Worked fairly well, with only a few cases making the program stall or fail (having to do with the data having sections that are backwards). A bit annoying... Though i did notice a big difference between code failing during running yet worked fine in a debugger (same executable). Some of this having to do with uninitialized values (which shouldn't be a problem in D) or the debugger using the stack and making it workable from some random pointer i could never find.
May 19 2019