Skip to content

Strict aliasing issue in vxWorks "intLib" stub #1167

@jphickey

Description

@jphickey

Describe the bug
When compiling with strict aliasing mode (gcc w/ -O3 -fstrict-aliasing -Wstrict-aliasing=2), a warning gets triggered in vxworks-intLib-stubs.c as follows:

osal/src/unit-test-coverage/ut-stubs/src/vxworks-intLib-stubs.c: In function ‘OCS_INUM_TO_IVEC’:
osal/src/unit-test-coverage/ut-stubs/src/vxworks-intLib-stubs.c:60:61: error: dereferencing type-punned pointer might break strict-aliasing rules [-Werror=strict-aliasing]
   60 |         UT_GetDataBuffer(UT_KEY(OCS_INUM_TO_IVEC), (void **)&VecTbl, &VecTblSize, NULL);
      |                                                             ^~~~~~~
cc1: all warnings being treated as errors

To Reproduce
Build with new-ish gcc (10.3) w/ -O3 -fstrict-aliasing -Wstrict-aliasing=2 options and tests enabled (so stubs are built).

Expected behavior
Should be clean.

System observed on:
Ubuntu

Additional context
Could be argued that stubs should not be built with optimization+strict aliasing rules, but the fix is relatively easy to avoid this warning.

Reporter Info
Joseph Hickey, Vantage Systems, Inc.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions