-
Notifications
You must be signed in to change notification settings - Fork 217
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
OSAL does not build cleanly with conversion warnings enabled #660
Comments
Ping @klystron78 |
Marked as topic for CCB discussion. Thus far we have not built any platform with |
There has also been stakeholder interest, in that some coding standards have a rule that is satisfied by supporting it. @tngo67 |
For discussion point - and one reason I recommend against sprinkling casts everywhere - consider this code. Note this does compile cleanly using
When run on a 32-bit x86 CPU one gets:
But the same code run on a 64-bit x86 CPU one gets:
So - only the first one - with NO forced types, instead relying on the intentional implicit type promotion rules documented in the C standard - works consistently across platforms. Where the type was forced the comparison result is inconsistent. |
|
Warning counts when using -Wconversion: |
Discussed w/ stakeholder and the consensus was to continue historical practice of spot checking with this flag to identify/resolve real issues, but we are not required to compile cleanly with this flag enabled. To close this out we can explicitly add |
Is your feature request related to a problem? Please describe.
OSAL does not build cleanly if
-Wconversion
warnings are enabled. In the CFE builds this warning is neither enabled nor disabled so it is left with the compiler default. Most gcc cross toolchains currently used disable it by default, but with the toolchain provided in VxWorks 7 this is enabled by default, so this difference becomes apparent.Describe the solution you'd like
First needs CCB discussion as to whether we want to be "conversion clean".
Downside is that it requires a bunch of extra type casting for things that would normally work implicitly without issue - which makes code ugly - and the casts can become outtdated/stale if the underlying type changes and that doesn't always generate a compiler message but can cause problems due to multiple conversions and/or changing for equality of wrong types. So unnecessary extra type casts can be a real risk to behavior, not just readability.
Upside is that every now and then it will identify a truncation or sign conversion issue that might be a real problem.
Once decided one way or the other, we should explicitly set the
-Wconversion
or-Wno-conversion
setting in CFE so that it is consistent and not dependent on compiler default.Additional context
Originally identified in #599 - split to separate issue (not limited to just VxWorks 7 - that's just what brought it up)
Requester Info
Joseph Hickey, Vantage Systems, Inc.
The text was updated successfully, but these errors were encountered: