NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

/Oa, /Ow (Assume No Aliasing, Assume Aliasing Across Function Calls)

Feature Only in Professional and Enterprise Editions   Code optimization is supported only in Visual C++ Professional and Enterprise Editions. For more information, see Visual C++ Editions.
/Oa
/Ow

Aliasing (the use of multiple names that refer to the same memory location) can prevent some optimizations, such as register storage of variables and loop optimizations.

/Oa tells the compiler that your program does not use aliasing.

Ow tells the compiler that your program does not use aliasing within functions but may use aliasing across function calls. As a result, pointer variables must be reloaded from memory after each function call.

Rules for using /Oa and /Ow

If you use /Oa or /Ow, you must follow these rules. The following rules apply for any variable not declared as volatile:

Failing to follow these rules can cause corrupted data. If variables seem to take on random values, compile the program with Disable (/Od). If the problem goes away, try compiling with optimization but without /Oa or /Ow.

The following code can cause an aliasing problem:

i = -100;
while( i < 0 )
{
    i += x + y;
    *p = i;
}

Without /Oa or /Ow, the compiler assumes that the assignment to *p can modify x or y, so it does not assume that x + y is constant for each iteration. If you specify /Oa or /Ow, the compiler assumes that modifying *p does not affect x or y and the calculation of x + y can be removed from the loop.

Note   You can disable optimizations around code that uses aliasing (for individual functions) by using #pragma optimize with the a or w option.

See Also

/O options (Optimize Code) | Compiler Options | Setting Compiler Options