N3561 Definition of the operands of _Generic --------------------------------------------- Author: Javier A. Múgica Purpose: Define an ambiguous concept Description ------------ Integer and arithmetic constant expressions restrict the operands they may contain: An integer constant expression [...] shall only have operands that are... Consider the ICE 0 || (0 && 1/0) in the light of the previous description we must conclude that the allowed operands refer to the expression's ultimate operands; in this example, 0, 0, 1 and 0. For neither 1/0 nor (0 && 1/0) are of the allowed kind. But if so, generic selections are not allowed, except in the cases where everything in them is constant. It is understood that generic selections are allowed or not according to their result expression, implying that the wording for integer and arithmetic constant expressions is not right. Proposal N3549, introducing the concept "discarded", fixes this, by allowing anything, in ICE and ACE, in expressions that are discarded, and by saying that _Generic discards all except the resulting expression. However, what N3549 exactly allows is *operands* that are discarded, and it is not clear what counts as operand in _Generic. Therefore we present here a proposal for defining what the operands of _Generic are. We present two alternatives. In the first one, that we call the cast-like one, only the controlling operand and the expressions of each generic association count as operands, just as in a cast expression the type name is not considered an operand. In the second one, the type-operands, the type names are also operands. If the second one is chosen, a slight adjustment to the wording for "Generic selection" presented in N3459 is needed, replacing "The generic selection discards its controlling operand and the expressions from the associations other than the result expression." by "The generic selection discards its controlling operand, all the type names and the expressions from the associations other than the result expression." There is no semantic difference in _Generic itself, since the type names cannot be variably modified; the change is needed to make correct the phasing in constant expressions that if all operands in an expression are ICE or discarded the expression is an ICE. Wording. 6.5.2.1 Generic selection ----------------------------------- Insert at the beginning of paragraph 3 (the first one in "Semantics") or, if it be preferred, under a "Description" section to be created. ** Alternative 1 (cast-like) The operands of a generic selection are its generic controlling operand and the expressions from each generic association. ** Alternative 2 (type-operands) The operands of a generic selection are its generic controlling operand as well as the type names and the expressions from each generic association. ("and the" and not just "and", to make clear that a pair type-name + expression is not a single operand)