<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - ObjC: negating 'self' should issue warning. E.g: typo in !self->value causes hard-to-catch problems"
href="https://bugs.llvm.org/show_bug.cgi?id=36861">36861</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>ObjC: negating 'self' should issue warning. E.g: typo in !self->value causes hard-to-catch problems
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>wkoszek@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Hello.
## Environment:
My Xcode: Version 9.2 (9C40b)
My clang version is below.
## Bug:
I've found this in one of our source files:
if (!self->writeCount || !self-readCount) {
NSLog(@"bleh");
}
In ObjC source code, it'd be great to treat 'self' a little more special.
Otherwise it's very easy to hit something like the thing above.
(note: there's no ->readCount; instead it's -readCount). `self` here is
negated, which makes the whole expression make sense. However it's not what the
person wanted. I know it's hard (as it's valid to test for if (!self), but
maybe there's some compiler magician who could suggest wrapping
"self-readCount" in braces, in which case we'd get:
weirdbug.m:30:33: error: arithmetic on pointer to interface
'SampleStream', which is not a constant size for this architecture and platform
## To replicate
git clone <a href="https://github.com/wkoszek/edu_objc.git">https://github.com/wkoszek/edu_objc.git</a>
cd edu_objc
make
The file is weirdbug.m.
=== my clang version ===
$ clang --version
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin17.4.0
Thread model: posix
InstalledDir:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>