What types of conversions are clearly redundant according to the standard?

I am confused by the rules regarding this question [a good URL can save time in answering]. I notice that a lot of conversion time works implicitly, but in other cases it required.

eg. I expected this to work:

long long a;
int b;
[..]
a = b * 1000;

but it turns out that "a" overflows and is required

a = (long long) b * 1000;

It was weird, since "a" was "big," I expected it to bother.

In any case, apart from this example, do you know an exhaustive source of information on this issue? No "most of the time is OK," it paranoid me.

EDIT: This is only the question "the second part does the calculation first and there it overflows, follow this rule"?

EDIT2: If there is a calculation, for example

long long a;
int b;
short c;
[..]
c = b + a * 3;

would fulfill

c = b + (int) a * 3; 

?

c = (short) b + (int) a * 3; 

, ,

c = (short) b + a * 3; 
+3
1

.

a = (b * 1000);

b * 1000, ( ) , long long. b 1000 int s, int. a .

, 1000 a long long.

a = b * 1000LL;

: 2:

  • a long long, b int, 3 int.
  • , a * 3 long long
  • , b + a*3 long long
  • c = b+a*3 , .
+6

Source: https://habr.com/ru/post/1758499/


All Articles