Mantis 1345

P1800-2008/D4

12.4.2 unique-if
12.5.3 unique case

 

CHANGE

12.4.2 unique-if and priority-if

 

...

A unique-if asserts that there is no overlap in a series of if–else–if conditions, i.e., they are mutually exclusive and hence it is safe for the expressions to be evaluated in parallel. In a unique-if, it shall be legal for a condition to be evaluated at any time after entrance into the series and before the value of the condition is needed. A unique-if shall be illegal if, for any such interleaving of evaluation and use of the conditions, more than one condition is true. For an illegal unique-if, an implementation shall be required to issue a warning, unless it can demonstrate a legal interleaving so that no more than one condition is true.

 

To implement this requirement, an implementation can continue the evaluation of conditions after a first true condition has been found and before the execution of the statement associated with the first true condition. However, the statements associated with any additional true conditions shall not be executed. An implementation shall also issue a warning if it determines that no condition is true, or it is possible that no condition is true, and the final if does not have a corresponding else.

 

TO

12.4.2 unique-if and priority-if

 

...

A unique-if asserts that there is no overlap in a series of if–else–if conditions, i.e., they are mutually exclusive and hence it is safe for the conditions expressions to be evaluated in parallel. In a unique-if, it shall be legal for a condition to be evaluated at any time after entrance into the series and before the value of the condition is needed. A unique-if shall be illegal if, for any such interleaving of evaluation and use of the conditions, more than one condition is true. For an illegal unique-if, an implementation shall be required to issue a warning, unless it can demonstrate a legal interleaving so that no more than one condition is true.

 

To implement this requirement, an implementation can continue the evaluation of conditions after a first true condition has been found and before the execution of the statement associated with the first true condition. However, the statements associated with any additional true conditions shall not be executed. An implementation shall also issue a warning if it determines that no condition is true, or it is possible that no condition is true, and the final if does not have a corresponding else.

 

In a unique-if, the conditions may be evaluated and compared in any order. The implementation shall continue the evaluations and comparisons after finding a matching condition. A unique-if is violated if more than one condition is found true. The implementation shall issue a warning and execute the statement associated with the true condition that appears first in the if statement, but not the statements associated with other true conditions.

 

After finding a uniqueness violation, the implementation is not required to continue evaluating and comparing additional conditions. The implementation is not required to try more than one order of evaluations and comparisons of conditions. The presence of side-effects in conditions may cause non-deterministic results.

An implementation shall also issue a warning if it determines that no condition is true, or it is possible that no condition is true, and the final if does not have a corresponding else.

 

CHANGE

12.5.3 unique-case and priority-case

...

In a unique-case, it shall be legal to evaluate a case item expression at any time after the evaluation of the case expression and before the evaluation of the corresponding comparison. A unique-case shall be illegal if, for any such interleaving of evaluations and comparisons, more than one case item matches the case expression. For an illegal unique-case, an implementation shall be required to issue a warning message, unless it can demonstrate a legal interleaving of evaluations and comparisons so that no more than one case item matches the case expression. To implement this requirement, an implementation can continue the evaluations and comparisons after the termination of the usual linear search and before the execution of the statement associated with the first matching case item. However, the statements associated with any additional matching case items shall not be executed.

 

TO (This will supercede the changes in Mantis 1041 to this paragraph)

 

12.5.3 unique-case and priority-case

...

In a unique-case, it shall be legal to evaluate a case item expression at any time after the evaluation of the case expression and before the evaluation of the corresponding comparison. A unique-case shall be illegal if, for any such interleaving of evaluations and comparisons, more than one case item matches the case expression. For an illegal unique-case, an implementation shall be required to issue a warning message, unless it can demonstrate a legal interleaving of evaluations and comparisons so that no more than one case item matches the case expression. To implement this requirement, an implementation can continue the evaluations and comparisons after the termination of the usual linear search and before the execution of the statement associated with the first matching case item. However, the statements associated with any additional matching case items shall not be executed.

 

In a unique-case, the case_expression shall be evaluated exactly once and before any of the case_item expressions. The case_item expressions may be evaluated in any order and compared in any order. The implementation shall continue the evaluations and comparisons after finding a matching case_item. A unique-case is violated if more than one case_item is found to match the case_expression. The implementation shall issue a warning and execute the statement associated with the matching case_item that appears first in the case statement, but not the statements associated with other matching case_items.

 

After finding a uniqueness violation, the implementation is not required to continue evaluating and comparing additional case_items. It is not a violation of uniqueness for a single case_item to contain more than one case_item expression that matches the case_expression. If a case_item expression matches the case_expression, the implementation is not required to evaluate additional case_item expressions in the same case_item. The implementation is not required to try more than one order of evaluations and comparisons of case_item expressions. The presence of side-effects in case_item expressions may cause non-deterministic results.