This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix fold_offsetof_1 (PR middle-end/41935)



Also, IMHO we shouldn't warn with -Warray-bounds for offsetof with
one past the last entry, as taking address of that is allowed in address
arithmetics and offsetof doesn't dereference that in any way.

We also shouldn't warn about array bounds for the last entry of a struct, like


typedef struct _VPD_IDENTIFICATION_DESCRIPTOR {
    UCHAR   CodeSet         : 4;
    UCHAR   Reserved        : 4;
    UCHAR   IdentifierType  : 4;
    UCHAR   Association     : 2;
    UCHAR   Reserved2       : 2;
    UCHAR   Reserved3;
    UCHAR   IdentifierLength;
    UCHAR   Identifier[1];
} VPD_IDENTIFICATION_DESCRIPTOR;
typedef VPD_IDENTIFICATION_DESCRIPTOR   *PVPD_IDENTIFICATION_DESCRIPTOR;

...

return offsetof (VPD_IDENTIFICATION_DESCRIPTOR, Identifier[4]);

(Saw that today in real-world code).

Paolo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]