Skip to content

Use null check instead of pointer comparison#701

Merged
mvandervoord merged 1 commit intoThrowTheSwitch:masterfrom
stevebroshar:replace-pointer-comparison-with-null-checking
Oct 9, 2023
Merged

Use null check instead of pointer comparison#701
mvandervoord merged 1 commit intoThrowTheSwitch:masterfrom
stevebroshar:replace-pointer-comparison-with-null-checking

Conversation

@stevebroshar
Copy link

The original code worked for xc8 v1.44, but does not compile with v2.45. I think the compiler failure is correct. In general, from what I understand of the C standard, it's not allowed to compare pointers unless they are to the same array or structure. I don't know how the compiler would know that and don't fully understand the reasoning for the rule, but maybe it's due to segmented memory addressing.

Anyway, the change I made should be logically equivalent; comparing both expected and actual against null rather than comparing them with each other.

Also, the comment above the change line was confusing so I re-wrote it.

This change fixes the issue I added last week, #700

@mvandervoord mvandervoord merged commit b175905 into ThrowTheSwitch:master Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants