[cfe-dev] _Generic constant string as controlling expression
bilbotheelffriend at gmail.com
Mon Dec 9 22:09:57 PST 2013
On Mon, Dec 9, 2013 at 1:47 PM, Richard Smith <richard at metafoo.co.uk> wrote:
> On Sun, Dec 8, 2013 at 2:16 PM, Prathamesh Kulkarni
> <bilbotheelffriend at gmail.com> wrote:
>> I am not able to understand why does the following code
>> fail to compile:
>> int main(void)
>> int x = _Generic("hello", char *: 1);
>> Compiling it with clang-3.2 gives the following error:
>> f.c:5:20: error: controlling expression type 'char ' not compatible
>> with any generic association type
>> int a = _Generic("hello", char *: 1);
>> n1570 $184.108.40.206 3rd point states:
>> "Except when it is the operand of the sizeof operator, the _Alignof
>> operator, or the
>> unary & operator, or is a string literal used to initialize an array,
>> an expression that has type ‘‘array of type’’ is converted to an
>> expression with type ‘‘pointer to type’’ that points to the initial
>> element of the array object and is not an lvalue. If the array object
>> has register storage class, the behavior is undefined."
>> Since this clause has no mention for _Generic, shouldn't the type of
>> be converted from char to char * when it's used as a controlling
>> expression ?
>> Or am I missing something ?
> Yes, I think it should -- this looks like a bug. Please file a bug report!
I browsed through the bug database, it seems it was already
>> Thanks and Regards,
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
More information about the cfe-dev