C28753

warning C28753: Relying on undefined order of evaluation of parameters

C/C++ allows the compiler to generate code to evaluate actual parameters in any order, and the x86 and Arm compilers tend to select different orders. Code that relies on a specific order may behave differently on different platforms.

A common mistake is with the use of smart pointers where the address-of operator & has side effects, in calls like this:

sp->Foo(&sp);

The calls to member access operator -> and operator & might happen in either order. Thus side effects from operator & might happen before or after operator -> is called. This warning finds these buggy calls to prevent different behavior between platforms.

Example

The code following example generates this warning.

sp->Foo(&sp)

The following code example avoids this warning.

SmartPtr spTemp;
sp->Foo(&spTemp);
sp = spTemp;