I have a ScopedLock class which can help to release lock automatically when running out of scope. However, the problem is: Sometimes team members write invalid
ScopedLock
AFAIK there's no such a flag in gcc. A static analyzer may better suit your needs.