Why is LLDB using the wrong field of my structure for arithmetic?

I am using a struct from cocos3d called CC3IntPoint:

typedef struct { GLint x; /**< The X-componenent of the point. */ GLint y; /**< The Y-componenent of the point. */ } CC3IntPoint; 

When I run my program, it looks fine in the debugger:

 (lldb) p pos (CC3IntPoint) $5 = { (GLint) x = 48 (GLint) y = 91 } (lldb) p pos.y (GLint) $6 = 91 

However, if I do any math on pos.y , it uses pos.x ! For instance:

 (lldb) p pos.y+1 (int) $7 = 49 (lldb) p pos.y*1 (int) $8 = 48 

Did I miss something obvious here? Any ideas on how to fix it?

+4
source share
1 answer

This is very much like a mistake.

Please register it.

I would say that this is some kind of arithmetic magic of a pointer, but I can not imagine that it is.

If you really want to study the problem, I would suggest capturing the address of various sub-exposures and see if you can find where it decides to capture the wrong field.

See Jason's comment on the original question; it really should be the answer.

+2
source

Source: https://habr.com/ru/post/1493865/


All Articles