Fedora Account System
Red Hat Associate
Red Hat Customer
Description of problem: Running sparse on a simple test.c containing just "#include <stdio.h>" gives: $ sparse test.c /usr/include/stdio.h:33:12: error: unable to open 'stddef.h' and sparse exits with '1' Trying this allows it to succeed for this test file: $ gcc_install="$(gcc --print-search | grep "install:" | cut -d' ' -f2)/include"; sparse -I$gcc_install test.c But seems to have spurious warnings if I add "#include <stdint.h>" to the test. /usr/lib/gcc/x86_64-redhat-linux/4.8.3//include/stdint-gcc.h:60:29: error: Expected ; at end of declaration /usr/lib/gcc/x86_64-redhat-linux/4.8.3//include/stdint-gcc.h:60:29: error: got int_least8_t /usr/lib/gcc/x86_64-redhat-linux/4.8.3//include/stdint-gcc.h:61:30: error: Expected ; at end of declaration /usr/lib/gcc/x86_64-redhat-linux/4.8.3//include/stdint-gcc.h:61:30: error: got int_least16_t ... Version-Release number of selected component (if applicable): 0.5.0-2.fc20 How reproducible: 100% Steps to Reproduce: 1. Create test.c containing: #include <stdio.h> #include <stdint.h> 2.Run: sparse test.c Actual results: Sparse fails Expected results: Saprse should pass Additional info:
I should note that this only started after gcc recently got updated to 4.8.3-1.fc20
Upstream sparse appears to work ok.
I'm afraid that this is just a fundamental limitation in the way sparse currently works. It defaults to looking for gcc headers in the location given by -DGCC_BASE. Once gcc is upgraded, then that no longer works by default since the headers will have moved. The reason "upstream sparse" works for you is because you built it with gcc that's currently installed. If you changed your gcc version after building it, you'd hit the same problem. It would be nice to have a proper fix for that sometime, but in the meantime you can use a command like this to work around it: $ sparse -gcc-base-dir `gcc --print-file-name=` /tmp/test.c ...with that, your testcase doesn't throw that warning. It would be nice if sparse were able to determine that automatically, but for now it doesn't. Feel free to complain on the upstream sparse list however (and send patches if you're able to do so).