On segunda-feira, 19 de agosto de 2013 16:29:40, Dmitrii Volosnykh wrote:
>     QFile file("test.json");
>     bool ok = file.open(QFile::WriteOnly | QFile::Truncate);
>     Q_ASSUME(ok);

Hmm... are you sure you know what the Q_ASSUME macro does?

You're using it where I would expect to see Q_ASSERT. For example, file 
creation is something that may fail at runtime. If it does, in the case above, 
your program goes into undefined behaviour after that Q_ASSUME.

You're only supposed to use it when you're *sure* it is always true. 

>From the docs:
    This macro could be considered a "lighter" version of \l{Q_ASSERT}. While
    Q_ASSERT will abort the program's execution if the condition is false,
    Q_ASSUME will tell the compiler not to generate code for those conditions.
    Therefore, it is important that the assumptions always hold, otherwise
    undefined behaviour may occur.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to