-Ona: Disable Alias Checking

Group

OPTIMIZATIONS

Scope

Function

Syntax
  -Ona
  
  
Arguments

None

Default

None

Defines

None

Pragmas

None

Description

After optimization, the Compiler redefines variables that may be written by a pointer indirection or an array access. This option prevents the Compiler from redefining these variables, which allows you to reuse already-loaded variables or equivalent constants. Use this option only when you are sure no real writes of aliases to a variable memory location will occur.

Example

Do not compile with -Ona.

  void main(void) {

  
    int a = 0, *p = &a;

  
    *p = 1; // real write by the alias *p

  
    if(a == 0) Error(); // if -Ona is specified,

  
    // Error() is called!

  
  }