Skip to content

Wcast-align=strict results in cast alignment errors with EDS build #891

@cf-ispace

Description

@cf-ispace

Checklist (Please check before submitting)

  • I reviewed the Contributing Guide.
  • I performed a cursory search to see if the bug report is relevant, not redundant, nor in conflict with other tickets.

Describe the bug
Enabling -Wcast-align=strict with EDS build enabled results in cast alignment warnings due to EDS defined structures having different alignment than the native structures, specifically with CFE_SB_Buffer_t and EdsNativeBuffer_CFE_HDR_CommandHeader_t (as compared to CFE_MSG_CommandHeader_t for non-EDS builds)

To Reproduce
Steps to reproduce the behavior:

  1. Checkout techdev-multitarget-bundle
  2. add -Wcast-align=strict to arch_build_custom.cmake compile options
  3. remove -Werror to see all the warnings
  4. make native_eds.compile

Expected behavior
No cast alignment warnings

Code snips
example warnings:

nasa-cfs/tools/eds/cfecfs/edsmsg/fsw/src/edsmsg_dispatcher.c:296:19: error: cast increases required alignment of target type [-Werror=cast-align]
  296 |     DispatchTbl = (const CFE_EDSMSG_DispatchFunc_t *)MemAddr;
...
nasa-cfs/apps/hs/fsw/src/hs_monitors.c: In function ‘HS_MonitorEvent’:
nasa-cfs/apps/hs/fsw/src/hs_monitors.c:341:43: warning: cast increases required alignment of target type [-Wcast-align]
  341 |                                 SendPtr = (CFE_SB_Buffer_t *)&HS_AppData.MATablePtr[MsgActsIndex].MsgBuf;
      |                                           ^
nasa-cfs/apps/hs/fsw/src/hs_monitors.c: In function ‘HS_ValidateMATable’:
nasa-cfs/apps/hs/fsw/src/hs_monitors.c:755:23: warning: cast increases required alignment of target type [-Wcast-align]
  755 |         BufPtr      = (CFE_SB_Buffer_t *)&TableArray[TableIndex].MsgBuf;
      |                       ^
...

System observed on:

  • Hardware: PC
  • OS: Ubuntu 22.04 64bit
  • Versions: v7.0.0

Additional context
Using GCC13

Reporter Info
Chris Fallon | ispace-US

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions