ThrowTheSwitch / Unity

Simple Unit Testing for C
ThrowTheSwitch.org
MIT License
4.02k stars 969 forks source link

Use null check instead of pointer comparison #701

Closed stevebroshar closed 12 months ago

stevebroshar commented 12 months ago

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