On 04/25/2013 06:44 PM, Maxim Fomin wrote:

> On Thursday, 25 April 2013 at 21:05:43 UTC, Ali Çehreli wrote:

> Looks like value range propagation bug because 1 is integer literal and
> should be converted to long. There is no way for 1 to be converted to
> bool here

That special conversion rule of literal 0 and literal 1 being implicitly convertible to false and true gets in the way.

> (from TDPL long is below int and it is the shortest way, value
> range propagation can work upwards, but the path would be longer).

Interesting.

I agree with bearophile, this is too surprising:

  foo(1);  // goes to bool

Decide to change the value:

  foo(2);  // now goes to long

Introduce a variable:

  int i = 1;
  foo(i);  // again, goes to long

I feel defeated. :)

Ali

Reply via email to