<html>
<head>
<base href="https://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 --- - -Wwrite-strings changes the actual type of string literals, meaning _Generic() behaves differently"
href="https://llvm.org/bugs/show_bug.cgi?id=27967">27967</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>-Wwrite-strings changes the actual type of string literals, meaning _Generic() behaves differently
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>ed@80386.nl
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Hi there,
Consider the following piece of code:
_Static_assert(_Generic("Hi", char *: 1), "");
This code builds by default, as string literals seem to be of type "char *".
Now build the code with -Wwrite-strings:
bla.c:1:25: error: controlling expression type 'const char *' not compatible
with any generic association type
This compiler warning flag changes the actual underlying type of string
literals. Though I can imagine why it's implemented this way, this behaviour is
problematic. It means that a compiler warning flag may actually influence the
behaviour of code. Consider the following:
bool has_been_built_with_write_strings = _Generic("", char *: false, const char
*: true);
The compiler flag trickles down into the way code is generated.</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>