In reply to dave_59:
Hi Dave ,
I understand the concept of using static cast eg: int’( item ) inside with () to avoid overflow cases .
I am unable to understand , how are these 2 different ::
a.sum() with ((item == 1) ? 1 : 0 ) == 10 ; // RHS of ? when true is 32-signed
a.sum() with ((item == 2) ? 2 : 0 ) == 5 ; // RHS of ? when true is 32-signed
a.sum() with ((item == 3) ? 3 : 0 ) == 5 ; // RHS of ? when true is 32-signed
**VS**
a.sum() with ((item == 1) ? 1 : 0 ) == 10 ; // RHS of ? when true is 32-signed
a.sum() with ((item == 2) ? 1 : 0 ) == 5 ; // RHS of ? when true is 32-signed
a.sum() with ((item == 3) ? 1 : 0 ) == 5 ; // RHS of ? when true is 32-signed
In both cases when condition is true , the RHS of ? is 32-bit signed .
When I write
a.sum() with ((item == 2) ? item : 0 ) == 5 ;
Since item is 4-bit , sum of 5 shouldn’t lead to overflow anyways .
I believe when condition ( item == 2 ) is true the item [ item would be 2 ALWAYS since ( item == 2 is True ) ] should be used to calculate sum .
So effectively reduced to
a.sum() with ( elements with value 2 ) == 5 ;
Please correct me if my interpretation it wrong .
EDIT :: The constraint reduces to ::
1 == 10 ; 2 == 5 ; 3 == 5 ;
Which can NEVER be true , hence the Failure !!