<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 --- - const with type safety checking [-Wtype-safety]" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D24022&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=pe3Cyw4l7MYHSGKm3-JygiMF2Ne0-1ug2DGxszC9xC0&s=86otETAnI4nZQR9jchZzpcQgI2qjz3HR0oGZSB4s6U0&e=">24022</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>const with type safety checking [-Wtype-safety]
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.6
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</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>jed@59a2.org
</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>MPI-3 changed read-only buffer arguments to use const. Clang's type tag system
is sensitive to const, meaning that a tag created for non-const cannot be used
for const without triggering a warning. For example, the following triggers a
warning:
$ cat warning.c
#define DATATYPE_INT 1
typedef int Datatype;
void f(const void *buf, Datatype tag)
__attribute__((pointer_with_type_tag(X,1,2)));
static const Datatype X_datatype_int
__attribute__((type_tag_for_datatype(X,int))) = DATATYPE_INT;
void foo(const int *data) {
f(data,DATATYPE_INT);
}
$ clang -c -Wtype-safety warning.c
warning.c:7:5: warning: argument type 'const int *' doesn't match specified 'X'
type tag that requires 'int *' [-Wtype-safety]
f(data,DATATYPE_INT);
^~~~ ~~~~~~~~~~~~
1 warning generated.
This causes superfluous warnings in idiomatic user code and has forced MPICH to
disable type tag checking with current Clang.
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__trac.mpich.org_projects_mpich_ticket_2223&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=pe3Cyw4l7MYHSGKm3-JygiMF2Ne0-1ug2DGxszC9xC0&s=spIT7CuF4DdJo2p-qJSunpWyKSwZ9n9j9iWgA1Y3ymk&e=">http://trac.mpich.org/projects/mpich/ticket/2223</a>
It would be much more useful behavior to let the normal C type system handle
const versus non-const arguments/conversions and have the tag system be
agnostic. Alternatively, make it possible to declare tags that are agnostic.</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>