Hi John, Peter and Ken:
I know a ticket has been entered and Appeon is looking into it, but wanted to add some thoughts...
It doesn't surprise me too much that when doing a comparison via the IF statement that promotion does not occur, with CONSTANTS, because my understanding is that promotion does not occur (or should not based upon the Help) with Relational operators (=, <= etc.) versus Arithmetic operators (+, -, / etc.). And maybe it has nothing to do with promotion but maybe since it is being declared and assigned at compile time as a certain datatype then it occupies the maximum number of bits required for a longptr at that point and the fact that both have a value of 177 is immaterial, they just won't compare to be the same...again, this is when using an IF statement, see below for a different result using CHOOSE CASE.
It more surprises me that promotion DOES occur with the non-CONSTANT expressions, such as with the test of ll_longptr and li_int in an IF statement. Or, maybe promotion is not taking place and it is concluding they are equal for a different reason. Possibly because they are the same value, maybe due to being declared with literals, but not how many bits they require for storage. What changes things is if you assign ll_longptr to li_int during li_int's declaration the comparisons are not equal as li_int ends up being equal to 0, which does not happen if you assign another integer variable to li_int during its declaration. However, if you don't give li_int a value during its declaration and assign ll_longptr to li_int afterwards then it works as before (demotion??). If it works, but not because of using literals, and assuming the Help is correct re promotion not taking place when using Relational operators, feels like something is not quite right.
What's interesting with the CHOOSE CASE statement and a CONSTANT of one data type and a non-CONSTANT of a different data type is that it seems to depend upon whether the CONSTANT is the testexpression (it does occur) versus the CONSTANT being one of the expressionlist entries (it does not occur). So in your example John, if you switch these around in your second CHOOSE CASE test you will see the "Alert 2" message. Again, planned behavior or is something not quite right!? FYI...in your fourth IF statement you actually compared ll_longptr (instead of ll_longptr_constant) to li_int_constant, but even when changed the message result is still the same as far as what occurs which is they are not considered equal.
While the above may be interesting, it's still confusing re the result of all these comparisons and so hopefully the ticket will yield some clarity. Maybe all is well and there is a logical explanation or maybe there is a bug, or two, that needs to be sorted out.
Again, just my thoughts and thanks for reading.
Regards,
Mark