[Mesa-dev] [PATCH 2/3] i965: Use unreachable() instead of unconditional assert().

Ian Romanick idr at freedesktop.org
Mon Jun 30 11:44:21 PDT 2014


On 06/30/2014 11:20 AM, Philipp Klaus Krause wrote:
> On 30.06.2014 20:03, Matt Turner wrote:
>> On Mon, Jun 30, 2014 at 10:37 AM, Ian Romanick <idr at freedesktop.org> wrote:
>>> In the cases where a return (with a value) is removed, I'm afraid static
>>> analysis tools will start to complain.  I'll be surprised if Klocwork
>>> understands (or trusts) GCC __builtin_unreachable decorations.
>>
>> Good catch. I didn't think about this.
>>
>> I did a little bit of searching and discovered this page:
>>
>> http://www.klocwork.com/products/documentation/current/Compiler_attributes_analyzed_by_Klocwork
>>
>> which fortunately says that Klocwork recognizes gcc's
>> __attribute__((noreturn)), so I feel relatively confident that
>> Klocwork recognizes __builtin_unreachable as well.
>>
>> If it doesn't and we get warnings from Klocwork, we can easily make
>> the unreachable() macro expand to a static inline function marked with
>> __attribute__((noreturn)).
> 
> Why use gcc-specific stuff instead of the standard _Noreturn/noreturn?

As far as I can see, _noreturn is a C11 feature... we can't even count
on C99 features in core Mesa yet, sooo... yeah. :) If we start to use
any sort of noreturn decoration, we should wrap it in a macro that
expands something the compiler can support.

> Philipp
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev



More information about the mesa-dev mailing list