<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - _Generic selection fails to select a compatible type"
href="http://llvm.org/bugs/show_bug.cgi?id=16340">16340</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>_Generic selection fails to select a compatible type
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>johnhuela@yahoo.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=10684" name="attach_10684" title="test case">attachment 10684</a> <a href="attachment.cgi?id=10684&action=edit" title="test case">[details]</a></span>
test case
_Generic selector fails to select any compatible type when a conversion from
array to pointer is needed although the standard clearly states:
$6.5.1.1 Generic selection
The controlling expression of a generic selection is not evaluated. If a
generic selection has a generic association with a type name that is compatible
with the type of the controlling expression, then the result expression of the
generic selection is the expression in that generic association. Otherwise, the
result expression of the generic selection is the expression in the default
generic association. None of the expressions from any other generic association
of the generic selection is evaluated.
In the case of:
_Generic("test", char *: 123)
The type of the controlling expression "test" is char[5], which is clearly
compatible with the type-name char* in the generic selection which should
return the int value 123.
Currently clang reports:
test.c:5:29: error: controlling expression type 'char [5]' not compatible with
any generic association type
printf("%d\n", _Generic("test", char *: 123));
^~~~~~
Which is wrong.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>