[cfe-dev] Q_ASSERT and Clang static analyzer

Dmitri Gribenko gribozavr at gmail.com
Fri Aug 23 15:40:55 PDT 2013


On Tue, Aug 20, 2013 at 10:00 AM, Jordan Rose <jordan_rose at apple.com> wrote:
>
> On Aug 20, 2013, at 9:50 , Stephen Kelly <steveire at gmail.com> wrote:
>
>> Jordan Rose wrote:
>>> Obviously, the best case is to get them to start using
>>> __attribute__((noreturn)) and/or __attribute__((analyzer_noreturn)). I can
>>> see adding qtFatal to the list, though, since Qt is a fairly widespread
>>> toolkit.
>>
>> qt_assert is already __attribute__((noreturn)).
>>
>> #ifndef Q_CC_MSVC
>> Q_NORETURN
>> #endif
>> Q_CORE_EXPORT void qt_assert(const char *assertion, const char *file, int
>> line) Q_DECL_NOTHROW;
>
> Then...why isn't it working? Dmitri, if you have a test case, please file a Bugzilla report, I guess.

OK, I found why.  Because the noreturn attribute was added to the
declaration only in Qt 5.  In Qt 4, which will be still relevant for
at least a few years from now, qt_assert is not marked with noreturn:

http://qt.gitorious.org/qt/qt/blobs/4.8/src/corelib/global/qglobal.h#line1815

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/



More information about the cfe-dev mailing list