FYI, this in http://llvm.org/PR4802
You might want to drop a note there in case anyone else is looking at this. On Wed, Jun 20, 2012 at 2:53 AM, Igor Minin <[email protected]> wrote: > Hello. > > The attached patch adds support for a clang -Wcast-qual option. Semantic > is compatible with the gcc one. > > Warn whenever a pointer is cast so as to remove a type qualifier from the >> target >> type. For example, warn if a "const char*" is cast to an ordinary "char*". >> Also warn when making a cast that introduces a type qualifier in an >> unsafe way. >> For example, casting "char**" to "const char**" is unsafe, as in this >> example: >> /* p is char ** value. */ >> const char **q = (const char **) p; >> /* Assignment of readonly string to const char * is OK. */ >> *q = "string"; >> /* Now char** pointer points to read-only memory. */ >> **p = ’b’; > > (Gcc manual). > > What is "introducing in an unsafe way" precisely described in [conv.qual] > item of C++ standard. > > So, the proposed patch is very similar to the code that checks assign > constrains. Differences are: > > * This patch generates only warnings, not errors, which helps to have > cleaner implementation. > * It is called only for C-style casting and functional-style casting > (because only three casts can remove qualifiers: C-sytle, functional-style > and const_cast. But const_cast in gcc is not generated warnings, so I > preserved this behaviour in clang). Other cases filtered by checks in > appropriate casts. > > Please, review. > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits > >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
