On Fri, 27 Jul 2012, Tom Tromey wrote: > I found this: > > https://groups.google.com/forum/?fromgroups#!topic/comp.std.c/InNlRotSWTc > > I wasn't really aware of 6.3.2.1, but after reading it and re-reading > 6.5.1.1, I think I agree with his "model 0" interpretation: no promotion > or conversion. > > I don't have a standards-based reason for this, though; just my belief > that _Generic was omitted from 6.3.2.1 by mistake. > > That's an amateur opinion though. I think it would be better for you to > say what you think.
I think there are three standards issues and two GCC issues: * Integer promotions. I think it's clear that those do not occur; a "short" value remains as "short" rather than "int". * Conversion of qualified to unqualified types (which normally would occur as part of lvalue-to-rvalue conversion, but might also be an issue with casts to qualified types). The given example of a cbrt type-generic macro would only work as users expect (given that an argument might be a variable of type "const long double", or a cast to const long double) if the expression (whether lvalue or rvalue) is converted from qualified to unqualified type. That suggests qualifiers should be discarded on the controlling expression (and if one of the type names specifies a qualified type, that case can never match). * Conversion of arrays and function designators to pointers. Given the removal of qualifiers it would seem natural for this to apply as well (to the controlling expression - not of course to the selected expression, given that this may explicitly be a function designator). But unlike the case of qualifiers, there's no real pointer in the standard to what's intended. And the GCC issues: * GCC doesn't have very well-defined semantics for whether an rvalue has a qualified type or not. This only appears as an issue with typeof at present, but does require more care about eliminating qualifiers for _Generic. * build_unary_op has code /* If the lvalue is const or volatile, merge that into the type to which the address will point. This is only needed for function types. */ that will give pointer-to-qualified type to expressions such as &abort - the address of a noreturn function. Again, at language level this is only visible with typeof at present. But in C11 terms, _Noreturn is not part of a function's type. This means that if the controlling expression is something such as &abort, with pointer-to-qualified-function type, the qualifiers on the pointer target type need to be removed for the comparisons. -- Joseph S. Myers jos...@codesourcery.com