Do the padding bytes of a POD type get copied?

后端 未结 4 1112
忘了有多久
忘了有多久 2021-01-03 17:21

Suppose I have a POD type like this:

struct A {
    char a;
    int b;
};

On my system, sizeof(A) == 8, even though size

4条回答
  •  抹茶落季
    2021-01-03 17:54

    It's not authoritative, but cppreference's entry for std::memcmp suggests that the padding bytes may differ:

    memcmp() between two objects of type struct{char c; int n;} will compare the padding bytes whose values may differ when the values of c and n are the same

提交回复
热议问题