<div class="gmail_quote">On Fri, Jun 3, 2011 at 18:34, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div id=":1gt">So it turns out that gcc has an option -Wconversion that warns one about ALL implicit conversions of sizes it does. This could be used to find all the places we pass PetscInt to MPI calls that require int but unfortunately it reports so much other stuff that it seems unusable. For example, see below.<br>
</div></blockquote><div><br></div><div>I think this other stuff can be dealt with. I use -Wconversion in Dohp and my builds are all clean [1]. It does report some things that really are not errors (e.g. positive integer literal becomes size_t and then is put back in int, but should be known at compile time to fit), but it has not been an inordinate amount of work to keep the builds clean. In the output you showed, it looks like most of the errors are coming through macros. The macros can probably be modified to silence them.</div>
<div><br></div><div>Clang also has -Wconversion. You could try building with a recent clang to see if it's as noisy.</div><div><br></div><div><br></div><div>[1] Except for a couple places where I use VALGRIND_MAKE_MEM_UNDEFINED() which has a bad conversion buried deep inside it's macro bowels. I work around this with the annotation</div>
<div><br></div><div>Â PragmaGCC(diagnostic ignored "-Wconversion")</div><div><br></div><div>which expands in terms of _Pragma() on systems that support it. Old versions of GCC don't support pragmas inside of function bodies, so they generate warnings if -Wconversion is turned on. Everything else works fine.</div>
<div><br></div><div>This pragma solution to selectively disable -Wconversion works for both GCC and Clang. It might also work for Intel and any other compilers that claim to be gcc-compatible-ish. On other compilers, you don't have to worry about -Wconversion because you just won't turn it on.</div>
</div>