Problem on adding two arrays

Hello everyone,
I have a question on adding two arrays together, illustrating using the following code.

real[int] vec1(2), vec2(2), vec3(2);
vec1 = 1.;
vec2 = 2.;
vec3 = 2*(vec1+vec2);

Then the code cannot run, with problem saying “error operator * , <7Add_KN_IdE>”. However, once I change the last sentence to the following

vec3 = 2 * vec1 + 2 * vec2;

Then the code is good to run. I’m really confused about how this problem occurs. Thanks if anyone can help.

The is due to c++ because you write 2*(vec1+vec2) you need a have a temporary array
so store de vector (vec1+vec2) (too expensive, so a do not code).