FTBFS if "-Werror=format-security" flag is used

Brendan Jones brendan.jones.it at gmail.com
Tue Dec 10 18:31:50 UTC 2013


On 12/06/2013 08:11 PM, Kevin Kofler wrote:
> Adam Jackson wrote:
>
>> On Fri, 2013-12-06 at 02:21 +0100, Kevin Kofler wrote:
>>
>>>      QString line;
>>>      line.fill( '-', 60 );
>>>      qDebug( line.ascii() );
>>> As you can see, the format string being passed here is provably constant.
>>
>> So fix the compiler.
>
> I don't think GCC will ever be able to prove that it is a constant. It would
> at least have to do intermodule inlining on the linked qstring.o to do that,
> which means qt3 would have to use the LTO support. Even then, I wouldn't
> count on it. Plus, if this construct were found in application code rather
> than in qt3 itself, GCC would even have to do the intermodule inlining on
> libqt-mt, which would also have negative consequences on binary
> compatibility.
>
> But knowing the contract of QString (Qt 3's in this case, but it's the same
> in Qt 4 and Qt 5), it's trivial for a human to prove it.
>
>          Kevin Kofler
>
What is the best way to handle this case:

qWarning(QObject::tr("Client name '%1' occupied.").arg(name).toUtf8());

something like, or can I make it simpler:

qWarning("%s",qPrintable(QObject::tr("Client name '%1' 
occupied.").arg(name).toUtf8()));

regards

Brendan


More information about the devel mailing list