CKTIS / C
Multiplication assignment operator (*=)
The *= operator multiplies the left operand's current value by the right operand and stores the result back. The left operand is evaluated only once.
Version: C23; repository compiler flag, production runtime not attested
Syntax
lhs *= rhslhs *= rhs corresponds to lhs = lhs * (rhs), but evaluates lhs only once. The left operand must be a modifiable lvalue of arithmetic type; pointers are not allowed.
Multiplication uses the usual arithmetic conversions, and the result is converted to the destination type. Overflow during multiplication in a signed integer type causes undefined behavior.
In the example, values[i++] *= 4 increments i only once. Do not assume, however, that *= specifies operand evaluation order.
Examples
#include <stdio.h>
int main(void)
{
int values[] = {6, 9};
int i = 0;
values[i++] *= 4;
printf("%d %d %d\n", values[0], values[1], i);
return 0;
}
Result
24 9 1
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.