#1941 closed defect (fixed)

Whither RTEMS_offsetof?

Reported by: Ralf Corsepius Owned by: Joel Sherrill
Priority: normal Milestone: 4.11
Component: score Version: 4.11
Severity: normal Keywords:
Cc: sebastian.huber@… Blocked By:


The RTEMS_offsetof macro in
is potentially producing bogus results.

The rationale is given in Linux's "man offsetof":


This macro is useful because the sizes of the fields that compose a structure can vary across implementations, and compilers may insert different numbers of padding bytes between fields. Consequently, an ele?

ment's offset is not necessarily given by the sum of the sizes of the previous elements.

A compiler error will result if member is not aligned to a byte boundary (i.e., it is a bit field).


rtems-gcc's > 4.6 toolchains implement "offsetof" as a define to builtin_offsetof in stddef.h. Older ones implement it as a macro which is more or less identical to RTEMS_offsetof (And thus also subject to this potential defect.).

IMO, RTEMS_offsetof should

  • either be entirely removed (and use-cases be replaced by "offsetof")


  • the macro's content changed to using "offsetof" instead of explicit and potentially broken address arithmetics.

Change History (3)

comment:1 Changed on Oct 20, 2011 at 6:01:13 AM by Sebastian Huber

Cc: Sebastian Huber added

comment:2 Changed on Nov 28, 2011 at 4:52:01 PM by Joel Sherrill

Resolution: fixed
Status: newclosed

Removed. Change noted in 4.11 release notes.

comment:3 Changed on Nov 24, 2014 at 6:58:28 PM by Gedare

Version: HEAD4.11

Replace Version=HEAD with Version=4.11 for the tickets with Milestone >= 4.11

Note: See TracTickets for help on using tickets.