Bug 326451 - Anonymous union are not properly displayed in variable viewer
Summary: Anonymous union are not properly displayed in variable viewer
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug-dsf-gdb (show other bugs)
Version: 8.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-28 14:50 EDT by Francis Giraldeau CLA
Modified: 2020-09-04 15:20 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Francis Giraldeau CLA 2010-09-28 14:50:55 EDT
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;
}
Comment 1 Francis Giraldeau CLA 2010-09-28 14:52:31 EDT
One small comment on the code: struct a shows the correct behavior, while struct c shows the bug
Comment 2 Marc-André Laperle CLA 2012-04-24 23:07:41 EDT
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.