Repository navigation
Conversation
LLVM flags these lines as unnecessary assignments because anObject is being both retained and then assigned back to itself. Removing the assignment addresses the warning without changing the code's existing behavior.
|
I've read your comments on issue #1 regarding your feelings on changing the code to hint the static analyzer. While I agree with that stance, I think addressing this particular issue as per the diff seems worthwhile as the intent of the existing code remains unchanged and no less clear. |
|
I've changed this for myself locally and am also of the opinion that it should be changed in the public repo. I don't think the assignment is harming anything but why have it if it serves no purpose. |
|
agreed |
, the code in the collection classes `+load` was removed and placed in a function with the `__attribute__ ((constructor))` attribute. This is to work around an apparent bug when building JSONKit as a static library for iOS targets. @ohhorob also opened a bug with apple- # 9461567.
|
This should be "fixed" in f403357. |
|
just curious: is there any reason not to just replace the line entirely instead of using the ifdef? |
|
"The experienced programmer looks both ways before crossing a one-way street." In a nutshell, the assignment is completely harmless if On the other hand, if someone has overridden The vast majority of the time, |
|
Also, this particular case is an excellent example of why I originally wrote this in the
Note: I wrote this before the What is the benefit to issuing a warning in this particular case? Will the "useless assignment" result in buggy behavior? Realistically, is it even possible for this "useless assignment" to change the behavior of the program? Are things improved if you remove the useless assignment in any way? IMHO, no. This |
|
Thanks for the update. On May 23, 2011, at 4:39 PM, johnezangreply@reply.github.com wrote:
|
|
n/p. While I have certain feelings towards these kinds of warnings from |
|
I'm not sure I understand under what circumstances anyone would ever override |
…ang#23. For issue johnezang#23, the code in the collection classes `+load` was removed and placed in a function with the `__attribute__ ((constructor))` attribute. This is to work around an apparent bug when building JSONKit as a static library for iOS targets. @ohhorob also opened a bug with apple- # 9461567.
|
@tonyarnold, the problem is that while it may be difficult for you or I to imagine "under what circumstances anyone would ever override As a practical example, imagine a Why would it do this? When a Now, it makes _zero_ practical difference if you write- obj = [obj retain];... compared to ... [obj retain];... except in the case when some thing does actually return a pointer such that In other words, |
|
Fair enough — you're very right about defensive coding, but still — it's a doozy of an edge case. Good explanation! Thanks for taking the time to write it :) |
|
"As a convenience, retain returns self because it may be used in nested expressions."
|
LLVM flags these lines as unnecessary assignments because anObject is being
both retained and then assigned back to itself. Removing the assignment
addresses the warning without changing the code's existing behavior.