Skip to content

Commit

Permalink
Fix max alignment for unions in typebuilder
Browse files Browse the repository at this point in the history
Since PR #1292 is merged, idlc calculates the alignment for a type
using the alignof function. This commit removes a workaround in the
typebuilder code for a bug in the old idlc alignment calculation.

Signed-off-by: Dennis Potman <[email protected]>
  • Loading branch information
dpotman authored and eboasson committed Oct 10, 2022
1 parent d2b0bc6 commit 8b7cb30
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/core/ddsi/src/ddsi_typebuilder.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,15 +785,14 @@ static dds_return_t typebuilder_add_union (struct typebuilder_data *tbd, struct
member_sz = sz;
}

tb_aggrtype->align = member_align; // FIXME: wrong alignment in idlc, should be: max(member_align, disc_align)

// union size (size of c struct that has discriminator and c union)
tb_aggrtype->size = disc_sz;
align_to (&tb_aggrtype->size, member_align);
tb_aggrtype->size += member_sz;

// padding at end of union
uint32_t max_align = member_align > disc_align ? member_align : disc_align;
tb_aggrtype->align = max_align;
align_to (&tb_aggrtype->size, max_align);

// offset for union members
Expand Down

0 comments on commit 8b7cb30

Please sign in to comment.