Submitter: Project Editor (Larry Jones)
Submission Date: 2012-01-18
Source: Edward Diener (comp.std.c)
Reference Document: N/A
It appears that #elif is not entirely equivalent to #else, #if, and #endif.
Consider the code:
#if this is not a valid expression
This is well-defined. Since the controlling expression of the #if evaluates to true, the #else group is skipped and thus the nested #if is only processed through the directive name (6.10.1p6).
However, if this is recast using #elif:
#elif this is not a valid expression
the #elif is not part of a group that is skipped and thus must be processed completely, including evaluating the controlling condition (even though the resulting value is of no interest).
I do not believe this was the committee's intent.
Suggested Technical Corrigendum
In 6.10.1p6, change:
Only the first group whose control condition evaluates to true (nonzero) is processed.
Only the first group whose control condition evaluates to true (nonzero) is processed; any following groups are skipped and their controlling directives are processed as if they were in a group that is skipped.
Previous Defect Report < - > Next Defect Report