<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Mon, Jun 12, 2017 at 10:10 AM Roman Lebedev via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">lebedev.ri added a comment.<br>
<br>
So i'm trying to analyze that stage2 warning.<br></blockquote><div><br>Could you link to the buildbot failure to see the original LLVM project code triggering this situation?<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The testcase //seems// to be: (autogenerated all the variants)<br>
<br>
void test_nop() {<br>
unsigned char **ptr1 = 0;<br>
void **ptr2 = (void **)ptr1;<br>
}<br>
void test_bad() {<br>
unsigned char **ptr1 = 0;<br>
const void **ptr2 = (const void **)ptr1; // expected-warning {{cast from 'unsigned char **' to 'const void **' must have all intermediate pointers const qualified to be safe}}<br>
}<br>
void test_good0() {<br>
unsigned char **ptr1 = 0;<br>
void *const *ptr2 = (void *const *)ptr1;<br>
}<br>
void test_good1() {<br>
unsigned char **ptr1 = 0;<br>
const void *const *ptr2 = (const void *const *)ptr1;<br>
}<br>
void test_good2() {<br>
unsigned char *const *ptr1 = 0;<br>
void *const *ptr2 = (void *const *)ptr1;<br>
}<br>
void test_good3() {<br>
unsigned char *const *ptr1 = 0;<br>
const void *const *ptr2 = (const void *const *)ptr1;<br>
}<br>
void test_good4() {<br>
const unsigned char **ptr1 = 0;<br>
const void **ptr2 = (const void **)ptr1;<br>
}<br>
void test_good5() {<br>
const unsigned char **ptr1 = 0;<br>
const void *const *ptr2 = (const void *const *)ptr1;<br>
}<br>
void test_good6() {<br>
const unsigned char *const *ptr1 = 0;<br>
const void *const *ptr2 = (const void *const *)ptr1;<br>
}<br>
<br>
GCC does not warn about such code at all, clang in C mode does warn about only one combination:<br>
<br>
$ gcc -c /tmp/test.c -Wcast-qual<br>
$ echo $?<br>
0<br>
$ clang -c /tmp/test.c -Wcast-qual<br>
/tmp/test.c:7:38: warning: cast from 'unsigned char **' to 'const void **' must have all intermediate pointers const qualified to be safe [-Wcast-qual]<br>
const void **ptr2 = (const void **)ptr1; // expected-warning {{cast from 'unsigned char **' to 'const void **' must have all intermediate pointers const qualified to be safe}}<br>
^<br>
1 warning generated.<br>
<br>
David, you reviewed the original `-Wcast-qual` patch, does all that ^ make sense?<br></blockquote><div><br>That seems like a reasonable warning, do you agree?<br><br>But maybe it's best to put it under another flag name so it doesn't collide with GCC.<br><br>But really - *shrug* I'd probably leave it under the same flag, fix the LLVM project code that causes it, and carry on.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
F3429854: gen.cpp <<a href="https://reviews.llvm.org/F3429854" rel="noreferrer" target="_blank">https://reviews.llvm.org/F3429854</a>><br>
<br>
<br>
Repository:<br>
rL LLVM<br>
<br>
<a href="https://reviews.llvm.org/D33102" rel="noreferrer" target="_blank">https://reviews.llvm.org/D33102</a><br>
<br>
<br>
<br>
</blockquote></div></div>