[llvm-bugs] [Bug 36861] New: ObjC: negating 'self' should issue warning. E.g: typo in !self->value causes hard-to-catch problems
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Mar 21 15:53:50 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=36861
Bug ID: 36861
Summary: ObjC: negating 'self' should issue warning. E.g: typo
in !self->value causes hard-to-catch problems
Product: clang
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: wkoszek at gmail.com
CC: llvm-bugs at lists.llvm.org
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 https://github.com/wkoszek/edu_objc.git
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
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180321/201b74a7/attachment.html>
More information about the llvm-bugs
mailing list