#pragma disjoint

Description

The #pragma disjoint directive lists the identifiers that are not aliased to each other within the scope of their use.

Syntax

Read syntax diagramSkip visual syntax diagram                                              .----------------------.
                                              V                      |
>>-#--pragma--disjoint--(--+---+--identifier----,--+---+--identifier-+--)-><
                           '-*-'                   '-*-'

Notes

The directive informs the compiler that none of the identifiers listed shares the same physical storage, which provides more opportunity for optimizations. If any identifiers actually share physical storage, the pragma may cause the program to give incorrect results.

An identifier in the directive must be visible at the point in the program where the pragma appears. The identifiers in the disjoint name list cannot refer to any of the following:

This pragma can be disabled with the -qignprag compiler option.

Example

int a, b, *ptr_a, *ptr_b;
#pragma disjoint(*ptr_a, b)	// *ptr_a never points to b
#pragma disjoint(*ptr_b, a)	// *ptr_b never points to a
void one_function()
{
     b = 6;
     *ptr_a = 7;	// Assignment does not alter the value of b
     another_function(b);	// Argument "b" has the value 6
}

Because external pointer ptr_a does not share storage with and never points to the external variable b, the assignment of 7 to the object that ptr_a points to will not change the value of b. Likewise, external pointer ptr_b does not share storage with and never points to the external variable a. The compiler can assume that the argument of another_function has the value 6 and will not reload the variable from memory.

Related information