I was trying to read through the C/C++ standard for this but I can't find the answer.
Say you have the following snippet:
int8_t m;
int64_t n;
And that at some point you perform m + n
, the addition itself is a binary operator and I think the most likely think that happen in such a case is:
- Wide
m
to the same size ofn
, call the widening resultm_prime
- Perform
m_prime + n
- Return a result of type
int64_t
I was trying to understand however if instead of performing m+n
I had performed n+m
the result would change (because maybe there could be a narrowing operations instead of a widening).
I cannot find the part of the standard that clarify this point (which I understand it could sound trivial).
Can anyone point me where I can find this in the standard? or what happens in general in situations like the one I exposed?
Personally I've been looking at the section "Additive operators" but it doesn't seem to me to explain what happens, pointer arithmetic is covered a bit, but there's no reference to some casting rule implicitly applied.
You can assume I'm talking about C++11, but any other standard I guess would apply the same rules.