Possible Bug With Nested Structs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello all,

I've built Pahole 1.15 from source on WSL Ubuntu. Though I have is a
very simple example of a C struct that doesn't seem to work correctly
if compiled as C++ via g++, though works fine when compiled as C via
gcc.

Is Pahole intended to work with code compiled as C++ (as opposed to
C)? If so, take a look at the simple test.c file (can be compiled via
gcc or g++). Also take a look at the output from running pahole
against the created executable. via both g++/gcc builds It seems like
the nested struct is duplicated if compiled on C++. Does this seem
like a bug?

In both cases, GCC is version 7.4.0.

test.c:
#include <stdint.h>

typedef struct _INNER {
    long myLong;
} INNER;

typedef struct _MY_STRUCT {
    struct
    {
        char a;
        int b;
        uint64_t ccc;
        uint8_t _8_1 : 1;
        uint8_t _8_4 : 4;
        uint8_t _8_3 : 3;
        INNER i;
    };

} MY_STRUCT;

int main()
{
    MY_STRUCT m;
    return 0;
}

pahole_g++:
csm10495@csm10495-desk:~$ g++ -g test.c && pahole a.out -q
struct _INNER {
        long int                   myLong;
};
struct _MY_STRUCT {
        struct {
                char                       a;
                int                        b;
                uint64_t                   ccc;
                uint8_t                    _8_1:1;
                uint8_t                    _8_4:4;
                uint8_t                    _8_3:3;
                INNER                      i;
        };

        struct {
                char               a;
                int                b;
                uint64_t           ccc;
                uint8_t            _8_1:1;
                uint8_t            _8_4:4;
                uint8_t            _8_3:3;
                INNER              i;
        };
};

pahole_gcc:
csm10495@csm10495-desk:~$ gcc -g test.c && pahole a.out -q
struct _INNER {
        long int                   myLong;
};
struct _MY_STRUCT {
        struct {
                char               a;
                int                b;
                uint64_t           ccc;
                uint8_t            _8_1:1;
                uint8_t            _8_4:4;
                uint8_t            _8_3:3;
                INNER              i;
        };
};


Thanks all.

- Charlie Scott Machalow



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux