Union of pointers is not shown correctly in Decompiler
See original GitHub issueDescribe the bug When creating structure with union of pointers to another structure on disasembly it appears to be shown incorectly in disassembler.
Screenshots
Main Structure
Union with pointers to structures
Dissassembly
Expected behavior When we have union in struture what is union of pointers to different structures i expect it to:
- be able to pick member of union
- show code in dissasembly view with actual union field and then eventually offset it. In this case we should get something like this
if (pUnit->eUnitType == UNITTYPE_Object) { *(D2ShrinesTxt **)(pUnit->pUnitData->pDataObject[8]) = pShrinesTxt; return; }
instead of code shown above on screenshot. - after rightclicking we should be able to select what union member we want to use.
Environment (please complete the following information):
- OS: Windows 10
- Java Version: jdk-11.0.2
- Ghidra Version: 9.0 (first public version)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:18
- Comments:18 (3 by maintainers)
Top Results From Across the Web
c++ - Union of object vs Union of pointers - Stack Overflow
Adding a constructor and a destructor made your code compileable, but it did not make it correct. The problem inherent in the original...
Read more >Igor's tip of the week #75: Working with unions - Hex Rays
In C, union is a type similar to a struct but in which all members (possibly of different types) occupy the same memory,...
Read more >Union in C - GeeksforGeeks
Like Structures, union is a user defined data type. In union, all members share the same memory location. For example in the following...
Read more >Type punning isn't funny: Using pointers to recast in C is bad.
I show you a technique to perform reinterpret casts safely in your own code. ... The compiler will treat both "puns" as unrelated...
Read more >Unionize Your Variables – An Introduction To Advanced Data ...
However, unlike a struct , the fields inside a union are not ... the compiler will pack them, so your code might not...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Having the ability to define unions at all seems kind of useless without this.
It’s been almost 2 years and this issue is still not resolved. Maybe we can have some more attention on this topic? Or at least official statement it will/will not be implemented. We are in this void for quite some time…