| Summary: | Anonymous union are not properly displayed in variable viewer | ||
|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | Francis Giraldeau <francis.giraldeau> |
| Component: | cdt-debug-dsf-gdb | Assignee: | Project Inbox <cdt-debug-dsf-gdb-inbox> |
| Status: | NEW --- | QA Contact: | Jonah Graham <jonah> |
| Severity: | normal | ||
| Priority: | P3 | CC: | francis.giraldeau, malaperle, mario.pierro, pawel.1.piech |
| Version: | 8.0 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | |||
One small comment on the code: struct a shows the correct behavior, while struct c shows the bug I can reproduce this with CDT 8.0.2 + gdb 7.4 (MinGW). Using -data-evaluate-expression (v2)->.x does work if I try to debug manually. |
Build Identifier: 20100218-1602 Under debuggin, named union inside struct displays each possible interpretation of a value: Name : x Binary:110000 Decimal:48 Other (Details):48 '0' Hex:0x30 Default:48 '0' Octal:060 An anonymous union displays this error: Failed to execute MI command: -data-evaluate-expression ((v2)->).x Error message from debugger back end: A syntax error in expression, near `).x'. It seems that the command sent to GDB is invalid. It should have been (v2)->x Reproducible: Always Steps to Reproduce: Compile and run the following C program : #include <stdio.h> #include <stdlib.h> struct a { union { unsigned char x; int y; } b; }; struct c { union { unsigned char x; int y; }; }; int main(void) { struct a *v1 = malloc(sizeof(struct a)); struct c *v2 = malloc(sizeof(struct c)); v1->b.x = '0'; printf("%i\n", v1->b.y); v2->x = '1'; printf("%i\n", v2->y); return EXIT_SUCCESS; }