-
Notifications
You must be signed in to change notification settings - Fork 208
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
Fix type mismatches and remove unnecessary typecasting #57
Comments
Imported from trac issue 26. Created by jphickey on 2015-01-21T13:46:44, last modified: 2019-03-05T14:57:55 |
Trac comment by jphickey on 2015-01-21 14:02:43: For a specific example of how extra typecasting can actually //break// things, consider the following code: {{{ result1 = input; printf("Input = %u, Results = %ld %ld\n", input, result1, result2); Compiling and executing this produces the following result: The first result (without any extra cast) is more likely the desired result. |
Trac comment by jphickey on 2015-01-26 15:04:17: Branch "trac-26-type_fixes" pushed -- commit [changeset:45f45f4] This grabs several low hanging fruits regarding signed/unsigned mismatches and unnecessary casts. |
Trac comment by jphickey on 2015-04-06 11:31:33: This is ready for review/merge |
Trac comment by sstrege on 2015-04-06 13:57:15: Concur with changes/merge |
Trac comment by acudmore on 2015-04-07 09:41:45: Concur. |
Trac comment by jwilmot on 2015-04-07 12:53:30: Concur. Why would we have signed task ids? Should we have a TaskID_t? |
Trac comment by glimes on 2015-04-07 13:01:01: Tested changeset [changeset:45f45f491] as part of the ic-2015-03-10 merge. |
Trac comment by glimes on 2015-04-13 15:24:53: Part of integration candidate 2015-03-10, |
Trac comment by glimes on 2016-02-25 10:17:32: these will be fixed in CFE 6.5 |
Trac comment by jhageman on 2019-03-05 14:57:55: Milestone renamed |
This ticket is to fix up areas of the code that have type mismatches or other unnecessary typecasting.
In the latter case, the type cast should be removed, because in certain situations it can actually interfere with the compiler doing the right thing and make it do the //wrong// thing instead. An example of this is casting to "int" with operands that are actually unsigned types and/or different widths. In the case that the forced "int" is a negative value, a sign extension might be performed and this might produce an unexpected result. In general, a cast should only be used when there is a good reason why the compiler's default conversion rules are not sufficient.
The text was updated successfully, but these errors were encountered: