Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strict aliasing issue in vxWorks "intLib" stub #1167

Closed
jphickey opened this issue Sep 28, 2021 · 0 comments · Fixed by #1168 or #1191
Closed

Strict aliasing issue in vxWorks "intLib" stub #1167

jphickey opened this issue Sep 28, 2021 · 0 comments · Fixed by #1168 or #1191

Comments

@jphickey
Copy link
Contributor

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.

@jphickey jphickey self-assigned this Sep 28, 2021
@jphickey jphickey added the bug label Sep 28, 2021
jphickey added a commit to jphickey/osal that referenced this issue Sep 28, 2021
Use a separate local variable rather than casting to (void **).
@astrogeco astrogeco added this to the cFS-Draco milestone Oct 6, 2021
astrogeco added a commit to astrogeco/osal that referenced this issue Nov 3, 2021
jphickey pushed a commit to jphickey/osal that referenced this issue Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants