[cfe-dev] "expression result unused" in comma expression

Chris Lattner clattner at apple.com
Fri Aug 31 14:51:41 PDT 2007


On Aug 28, 2007, at 11:30 AM, Chris Lattner wrote:

>>> So the y+2 is unused.  I will fix the diagnostic to be more precise.
>>
>> Thanks for pointing this out.  On a related matter, it does appear
>> that this check doesn't handle statement expressions (unless I'm,
>> quite possibly, also reading this wrong!):
>>
>> int maxval_stmt_expr(int x, int y) {
>>   return ({int _a = x, _b = y; _a > _b ? _a : _b; });
>> }
>>
>> warning: expression result unused
>>   return ({int _a = x, _b = y; _a > _b ? _a : _b; });
>>                                ^~~~~~~~~~~~~~~~~
>>
>> (it's pointing to the ternary expression)
>
> You are right, it doesn't handle them yet.  This is a bug in the
> warning that I haven't addressed yet.

Fixed.

-Chris



More information about the cfe-dev mailing list