News for hackers. Stuff that matters.
Re:Help improve gcc by kazinator on Monday October 06, 2014 @04:16PM (#8418004)
Oh, you need helpers to improve diagnostics, do you?

How about you merge the fscking C++ diagnostic I wrote more than 6 years ago which is sitting in your Bugzilla (with patches!) collecting dust.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36587

What this does is warn you about constructs where you are using an object for its construction side effect, but forget to give the declaration a name:

    void foo::bar()
    {
      mutexlocker(&my_mutex);
      // critical section
    }
This should be:

    void foo::bar()
    {
      mutexlocker locker(&my_mutex);
      // critical section
    }
Without the name, it's just a constructor call that doesn't define an object that is scoped around the block, and so the mutex is not locked around the critical section. Its value is discarded and that's that. If it's not optimized away, it will do a quick lock and unlock.

I developed this while working as the "guy who makes the from-scratch embedded Linux + toolchain distro". The app developers on the same project wrote a large C++ application, and made this mistake in more than one place, so I whipped up this diagnostic for them.

Re:Help improve gcc by slavik81 on Monday October 06, 2014 @05:24PM (#8418388)
cppcheck will find this sort of error, though a compiler warning would be nicer. I've definitely made this mistake before and not noticed until check-in.