On 13/03/2016 01:59, Nathan Kurz wrote:
Clang: ../src/CFCPython.c:141:9: warning: string literal of length
8477 exceeds maximum length 4095 that ISO C99 compilers are required
to support [-Woverlength-strings] "static PyObject*\n"
GCC: ../src/CFCPython.c: In function ‘S_gen_callbacks’:
../src/CFCPython.c:352:9: warning: string length ‘8477’ is greater
than the length ‘4095’ ISO C99 compilers are required to support
[-Woverlength-strings]
This seems to be a harmless warning resulting from the `-pedantic` switch. I
decided to add `-Wno-overlength-strings` to our compile flags.
ICC does offer some nice optimization diagnostics. Assuming most
people aren't using it, I've attached a sample here for
"-qopt-report=4 -qopt-report-phase cg,ipo,loop,par,vec" which might be
worth glancing at.
I could only find an attachment with the leak sanitizer output.
As Nick hints, there are a _lot_ of warnings that appear for all the
compilers if you add -Wconversion to CFLAGS. Note that these warnings
are in addition to -Wextra. For library code like this, it's probably
worth adding this flag, and fixing the warnings. While most are false
alarms, there are likely are some real bugs hiding in there.
I'm a big fan of -Wconversion and I'd encourage everyone starting with a new C
project to use this flag from the beginning. Adding this flag to existing
projects takes a lot of effort, though.
I also tested with "-fsanitize=address". This reported a couple
dozen potential leaks, although I don't know if they are real or just
testing artifacts. I've attached the report in case someone with
more knowledge wants to check.
There are a couple of known leaks in the test suite. You should compile with
LUCY_VALGRIND=1 to ignore them.
I tjhen tested to see if adding "-fsanitize=undefined" (GCC and
Clang), and "-fsanitize=memory" (Clang only) reported anything, but
these came up clean. I only tested for 'compiler/c', though, might
be worth trying the other directories.
The various -fsanitize options are really useful, and surprisingly
underutilized. it probably would be good practice to start testing
with them. Adding them to CFLAGS is a bit difficult in this project,
but using "CC='clang -fsanitize=address' configure" seems to work.
We regularly test with Valgrind and from my experience it catches more errors
than -fsanitize=address and -fsanitize=memory. An -fsanitize build is a lot
faster than testing with Valgrind, though, and -fsanitize=undefined adds some
additional diagnostics, so we should provide an easy way to test with these flags.
Nick