Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A warning does not necessarily mean you've done something wrong, but tells you that you <em>might</em> not have intended this behaviour. Note that a compiler is allowed to warn about anything the developers considered worth warning about. In principle, you could also be warned about compiling on Friday the 13th.</p> <p>In this specific case the assumption probably is that when you specify alignment, you don't want to make the class bigger. Therefore if the class gets bigger due to the alignment requirement you gave, it's not unlikely that you made a mistake.</p> <p>Of course that leaves the question why the alignment requirement makes the class bigger. Now we are back in standards land (although the <code>__declspec</code> itself is a Microsoft extension and not standard). The C++ standard requires that in arrays, the objects follow each other without any space in between. Therefore if your objects must be aligned to 16-byte boundaries, the object must have a size which is a multiple of 16. If the size of the members (both explicit and implicit) doesn't give the necessary size, the compiler has to add unused bytes to the object. These bytes are called padding. Note that this padding is present even in objects which are not members of arrays.</p> <p>Now your class only contains an implicit virtual pointer (because it contains virtual functions) which, depending on the architecture, probably is either 4 or 8 bytes large. Since you've requested 16 byte alignment, the compiler has to add 12 or 8 bytes of padding to get the size to a multiple of 16, which it would not have had to add without that manual alignment specification. And this is what the compiler warns about.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload