<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sun, Dec 8, 2013 at 2:16 PM, Prathamesh Kulkarni <span dir="ltr"><<a href="mailto:bilbotheelffriend@gmail.com" target="_blank">bilbotheelffriend@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I am not able to understand why does the following code<br>
fail to compile:<br>
<br>
int main(void)<br>
{<br>
  int x = _Generic("hello", char *: 1);<br>
}<br>
<br>
Compiling it with clang-3.2 gives the following error:<br>
f.c:5:20: error: controlling expression type 'char [6]' not compatible<br>
with any generic association type<br>
  int a = _Generic("hello", char *: 1);<br>
<br>
n1570 $6.3.2.1 3rd point states:<br>
"Except when it is the operand of the sizeof operator, the _Alignof<br>
operator, or the<br>
unary & operator, or is a string literal used to initialize an array,<br>
an expression that has type ‘‘array of type’’ is converted to an<br>
expression with type ‘‘pointer to type’’ that points to the initial<br>
element of the array object and is not an lvalue. If the array object<br>
has register storage class, the behavior is undefined."<br>
<br>
Since this clause has no mention for _Generic, shouldn't the type of "hello"<br>
be converted from char[6] to char * when it's used as a controlling expression ?<br>
Or am I missing something ?<br></blockquote><div><br></div><div>Yes, I think it should -- this looks like a bug. Please file a bug report!</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Thanks and Regards,<br>
Prathamesh<br>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br></div></div>