digitalmars.D - FWIW: results of cppcheck on dmd sources
- Trass3r (6/6) Jun 19 2012 http://trass3r.github.com/dmd-cppcheck/
- bearophile (7/8) Jun 19 2012 Beside the usual "Unused variable: xxxx", and the nice "Variable
- Walter Bright (3/8) Jun 19 2012 Thanks for posting this. I think these are worth correcting, although in...
- Brad Anderson (19/31) Jun 19 2012 CppCheck is actually how I found the two bugs I fixed recently
- Trass3r (1/3) Jun 19 2012 This is news to me. Has the GC been re-enabled?
- Walter Bright (3/5) Jun 19 2012 No, it's just that cppcheck doesn't (and cannot) detect global memory le...
- Trass3r (2/5) Jun 19 2012 btw, what is the stance on adding some manual memory freeing, at least f...
- Walter Bright (2/8) Jun 19 2012 I think it's fine, but it has to be done carefully to avoid bugs.
- Walter Bright (4/11) Jun 19 2012 I think in general fixing cppcheck's complaints makes the code more
- Trass3r (1/4) Jun 19 2012 +1
- Trass3r (1/1) Jun 19 2012 http://trass3r.github.com/dmd-clang/
http://trass3r.github.com/dmd-cppcheck/ Seems like the tool isn't dead after all so I tried it out with the dmd sources. Some false positives but also some valid points. E.g. http://trass3r.github.com/dmd-cppcheck/15.html#line-960 looks particularly interesting.
Jun 19 2012
Trass3r:http://trass3r.github.com/dmd-cppcheck/Beside the usual "Unused variable: xxxx", and the nice "Variable 'xxx' is assigned a value that is never used", I see an uncommon class of suggestions, "The scope of the variable 'xxxxx' can be reduced." that is simple but useful. Bye, bearophile
Jun 19 2012
On 6/19/2012 7:05 AM, Trass3r wrote:http://trass3r.github.com/dmd-cppcheck/ Seems like the tool isn't dead after all so I tried it out with the dmd sources. Some false positives but also some valid points. E.g. http://trass3r.github.com/dmd-cppcheck/15.html#line-960 looks particularly interesting.Thanks for posting this. I think these are worth correcting, although in my quick scan I didn't see any actual bugs.
Jun 19 2012
On Tuesday, 19 June 2012 at 17:10:03 UTC, Walter Bright wrote:On 6/19/2012 7:05 AM, Trass3r wrote:CppCheck is actually how I found the two bugs I fixed recently (CtfeStack::maxStackPointer and ComplexExp::toChars). I spent a couple hours going through the results of CppCheck but only found those two actual problems (plus the third Globals thing that turned out to not be a problem). That's not to say I thoroughly investigated every item. There sure are a lot of unused variables in DMD :P. I didn't feel qualified to submit a pull request removing them as I don't have a very strong understanding of DMD's source code yet. One non-bug I thought about addressing but didn't end up doing was this: http://trass3r.github.com/dmd-cppcheck/18.html#line-4259 I looked up the file history and it seems like that's just a result of Don doing some refactoring. There are surprisingly few notices of memory leaks considering DMD uses a GC. Regards, Brad Andersonhttp://trass3r.github.com/dmd-cppcheck/ Seems like the tool isn't dead after all so I tried it out with the dmd sources. Some false positives but also some valid points. E.g. http://trass3r.github.com/dmd-cppcheck/15.html#line-960 looks particularly interesting.Thanks for posting this. I think these are worth correcting, although in my quick scan I didn't see any actual bugs.
Jun 19 2012
There are surprisingly few notices of memory leaks considering DMD uses a GC.This is news to me. Has the GC been re-enabled?
Jun 19 2012
On 6/19/2012 10:54 AM, Trass3r wrote:No, it's just that cppcheck doesn't (and cannot) detect global memory leaks - only very localized ones.There are surprisingly few notices of memory leaks considering DMD uses a GC.This is news to me. Has the GC been re-enabled?
Jun 19 2012
btw, what is the stance on adding some manual memory freeing, at least for obvious local leaks?This is news to me. Has the GC been re-enabled?No, it's just that cppcheck doesn't (and cannot) detect global memory leaks - only very localized ones.
Jun 19 2012
On 6/19/2012 1:41 PM, Trass3r wrote:I think it's fine, but it has to be done carefully to avoid bugs.btw, what is the stance on adding some manual memory freeing, at least for obvious local leaks?This is news to me. Has the GC been re-enabled?No, it's just that cppcheck doesn't (and cannot) detect global memory leaks - only very localized ones.
Jun 19 2012
On 6/19/2012 10:29 AM, Brad Anderson wrote:CppCheck is actually how I found the two bugs I fixed recently (CtfeStack::maxStackPointer and ComplexExp::toChars). I spent a couple hours going through the results of CppCheck but only found those two actual problems (plus the third Globals thing that turned out to not be a problem). That's not to say I thoroughly investigated every item. There sure are a lot of unused variables in DMD :P. I didn't feel qualified to submit a pull request removing them as I don't have a very strong understanding of DMD's source code yet.I think in general fixing cppcheck's complaints makes the code more understandable and maintainable, even if it doesn't actually fix anything. A lot of the cruft in the code comes from the endless turmoil it undergoes :-)
Jun 19 2012
I think in general fixing cppcheck's complaints makes the code more understandable and maintainable, even if it doesn't actually fix anything.+1
Jun 19 2012