[cfe-dev] [Clang 3.0] Inconsistent warnings about assignment in a condition

Alexei Sholik alcosholik at gmail.com
Fri Mar 16 14:12:17 PDT 2012


Thanks, John.

I have filed a bug report http://llvm.org/bugs/show_bug.cgi?id=12285

On 16 March 2012 22:45, John McCall <rjmccall at apple.com> wrote:
> On Mar 16, 2012, at 12:44 AM, Alexei Sholik wrote:
>> I can't find a way to make Clang _always_ trigger warnings about
>> assignment inside a condition. When I create a new project (Mac or
>> iOS) in Xcode 4.3.1 and compile it, the following code does not
>> trigger any warnings:
>>
>> - (id)init
>> {
>>    if (self = [super init]) {
>>        // ...
>>    }
>>    return self;
>> }
>
> We wanted to enable -Wparentheses by default, but we got a lot of pushback
> over this specific idiom (particularly since Apple puts out example code
> with this verbatim), so we moved it to a subgroup -Widiomatic-parentheses
> that is not enabled by default.  If you specifically enable -Wparentheses
> instead of relying on the default behavior, you should see warnings about
> this.
>
>> BUT, in the same project I don't get any warnings in the following case:
>>
>>        if (self.uid = 11) {
>>            // ...
>>        }
>>
>> Is this behavior expected? Which flag should I use in order for the
>> compiler to catch this case too?
>
> This is an oversight caused by a recent refactor;  please file a bug.
>
> John.



-- 
Best regards
Alexei Sholik




More information about the cfe-dev mailing list