This is the mail archive of the gcc-bugs@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]

[Bug other/52944] [4.5/4.6 Regression] __builtin_object_size(..., 1) no longer returns (size_t)-1 for consecutive flexible/zero-length array members


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52944

Mike Frysinger <vapier at gentoo dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.4.7
      Known to fail|                            |4.5.3, 4.6.3

--- Comment #2 from Mike Frysinger <vapier at gentoo dot org> 2012-04-12 15:13:25 UTC ---
if you look at the tftp example, you'd see that your proposed struct does not
work.  the protocol needs two flexible array members at different starting
points.

the 96 isn't conservative in this case, it's correct.  i declared a buffer of
100 bytes, so buf[0] can cover 96 bytes (as the leading integer is 32bits).  is
there a "simplish" patch that could be backported to the 4.5/4.6 branches for
that ?

thinking a bit more, the requirements can probably be pulled off with more
anonymous unions/structs like so:

struct tftphdr {
    short opcode;
    union {
        struct {
            union {
                unsigned short tu_block;
                short tu_code;
            };
            char tu_data[0];
        };
        char tu_stuff[0];
    } __attribute__ ((__packed__));
} __attribute__ ((__packed__));


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