[Bug middle-end/48269] New: Incorrect fortify warning for a packed struct member

ismail at namtrac dot org gcc-bugzilla@gcc.gnu.org
Thu Mar 24 10:02:00 GMT 2011


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

           Summary: Incorrect fortify warning for a packed struct member
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: ismail@namtrac.org


[~]> g++-4.6 -m32 -O2 -fstack-protector -c kis_droneframe.ii 
In file included from packet.h:37:0,
                 from kis_droneframe.cc:28:
packet_ieee80211.h:248:40: warning: ‘packed’ attribute ignored [-Wattributes]
packet_ieee80211.h:253:43: warning: ‘packed’ attribute ignored [-Wattributes]
packet_ieee80211.h:273:43: warning: ‘packed’ attribute ignored [-Wattributes]
In file included from /usr/include/stdio.h:912:0,
                 from util.h:24,
                 from kis_droneframe.cc:25:
In function ‘int snprintf(char*, size_t, const char*, ...)’,
    inlined from ‘virtual int KisDroneFramework::SendSource(int,
pst_packetsource*, int)’ at kis_droneframe.cc:507:49:
/usr/include/bits/stdio2.h:66:75: warning: call to int
__builtin___snprintf_chk(char*, unsigned int, int, unsigned int, const char*,
...) will always overflow destination buffer [enabled by default]

Now the said line is;

        snprintf((char *) spkt->type_str, 16, "%s",
                 in_int->strong_source->FetchType().c_str());


where spkt is defined as;

struct drone_source_packet {
    uint16_t source_hdr_len;
    uint32_t source_content_bitmap;
    drone_trans_uuid uuid;
    // Kill this source, the rest of the data is empty
    uint16_t invalidate;
    // Null-terminated strings
    uint8_t name_str[16];
    uint8_t interface_str[16];
    uint8_t type_str[16];
    uint8_t channel_hop;
    uint16_t channel_dwell;
    uint16_t channel_rate;
} __attribute__((__packed__));

Using gcc version 4.6.0 20110314 [gcc-4_6-branch revision 170941] (SUSE Linux)



More information about the Gcc-bugs mailing list