infer icon indicating copy to clipboard operation
infer copied to clipboard

DEAD_STORE - False Positive

Open hissain opened this issue 2 years ago • 2 comments

Please make sure your issue is not addressed in the FAQ.

infer version 1.1.1_0 OS: Catalina

I am using CocoaLumberjack pod in my iOS project.

Defined custom macro like,

#define SM_DDLogDebugConst(tag, frmt)   DDLogDebug(([NSString stringWithFormat:@"[DEBUG][%@] %@", tag, frmt]), @"%@")

In code I used the macro like following,

int64_t startTime = [TimeUtils NOW]; // returns timestamp // line = 10
...
int64_t tempTime = [TimeUtils NOW];
SM_DDLogDebug(TAG_Class, @"elapsed time: %lld", (tempTime - startTime));
...

The problem is when I run infer its detecting DEAD_STORE error in line 10 through the variable in the line has been used in the logging. How to resolve this issue?

hissain avatar Jan 10 '22 17:01 hissain

Could it be that the macro is compiled out so infer doesn't see the use of the variable inside of it? Is there a way for you to build with logging enabled when using infer?

jvillard avatar Jan 11 '22 11:01 jvillard

@jvillard I also suspect that the macros are creating problems. But I am building with below command,

xcodebuild clean build -workspace Project.xcworkspace -scheme Main -configuration CustomDebug COMPILER_INDEX_STORE_ENABLE=NO OTHER_CFLAGS="-DNS_FORMAT_ARGUMENT(A)= -D_Nullable_result=_Nullable" | tee xcodebuild.log | /usr/local/bin/xcpretty -r json-compilation-database -o compile_commands.json

infer run --keep-going --skip-analysis-in-path Pods --compilation-database-escaped compile_commands.json

And in CustomDebug configuration logging is already enabled. So how can I check other options and resolve it?

hissain avatar Jan 18 '22 07:01 hissain