Partager via


/Oa - Assume No Aliasing

This option informs the compiler that the referenced program does not use aliasing. An alias is a name that refers to a memory location already referred to by a different name.

The /Ow - Assume Aliasing Across Function Calls option tells the compiler that no aliasing occurs within function bodies but might occur across function calls. After each function call, you must reload pointer variables from memory.

The following rules must be followed for any variable not declared as volatile, or else /Oa and /Ow are ignored. In these rules, a variable is referenced if it is on either side of an assignment or if a function uses it in an argument:

  • No pointer references a variable used directly.
  • No variable is used directly if a pointer to the variable is being used.
  • No variable is used directly if the variable's address is taken within a function.
  • No pointer is used to access a memory location if another pointer is used to modify the same memory location.

Aliasing bugs most frequently show up as corrupted data. If variables are assigned seemingly random values, compile the program with /Od - Disable Optimization. If the program works when compiled with the /Od option, do not use /Oa or /Ow.

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

See Also

About Microprocessor Compilers | ARM Guide | Hitachi Guide | MIPS Guide | /Ow - Assume Aliasing Across Function Calls

 Last updated on Thursday, April 08, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.