Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix format-security GCC error (GH-64) #65
Although your commit fixes the warning, it's incorrect and breaks the code using the function.
There are two cases here:
std::string message = 0 > 0 ? strprintf("this is msg") : "this is msg";
You'll see that the middle part is dead code (0 is never greater than 0). GCC still issues the
std::string message = 1 > 0 ? strprintf("this is msg with %d formatting", 42) : "this is msg with %d formatting";
If you really don't want to disable
Edit: Actually, there's an easier solution: we can just add overloads to Warning()/Error() without the extra formatting arguments that don't call strprintf(). That would duplicate some code, though.