Skip to content

Commit

Permalink
Fix IPAddress packed layout and iovector flex array (#352)
Browse files Browse the repository at this point in the history
* Fix IPAddr memory layout

* Ignore GCC13 new warning for flex array inheritance
  • Loading branch information
Coldwings authored Feb 6, 2024
1 parent 0801372 commit 1bf5242
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion common/iovector.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ inline void delete_iovector(iovector* ptr);

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
#if __GNUC_MINOR__ >= 13
#pragma GCC diagnostic ignored "-Wzero-length-bounds"
#pragma GCC diagnostic ignored "-Wstrict-flex-arrays"
#endif

class iovector
{
Expand Down Expand Up @@ -861,7 +865,7 @@ class iovector

struct IOVAllocation_ : public IOAlloc
{
void* bases[0];
void* bases[];
void* do_allocate(int size, uint16_t& nbases, uint16_t capacity)
{
return do_allocate(size, size, nbases, capacity);
Expand Down
2 changes: 1 addition & 1 deletion net/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace net {
union {
in6_addr addr = {};
struct { uint16_t _1, _2, _3, _4, _5, _6; uint8_t a, b, c, d; };
};
} __attribute__((packed));
// For compatibility, the default constructor is still 0.0.0.0 (IPv4)
IPAddr() {
map_v4(htonl(INADDR_ANY));
Expand Down

0 comments on commit 1bf5242

Please sign in to comment.