Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 362603

Summary: "possible assignment in condition" invalid for correct assignment
Product: [Tools] CDT Reporter: Martin Nowack <martin>
Component: cdt-codanAssignee: CDT Codan Inbox <cdt-codan-inbox>
Status: RESOLVED WORKSFORME QA Contact: Elena Laskavaia <elaskavaia.cdt>
Severity: normal    
Priority: P3 CC: cdtdoug, chfast, yevshif, zeratul976
Version: 8.0   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Martin Nowack CLA 2011-11-01 17:13:46 EDT
Build Identifier: 20110916-0149

testcase:
	if (llvm::Value * c = dyn_cast<llvm::Value>(val)) {
		
	}

The analyzer marks "c" as unresolved symbol and therefore assumes that there might be an invalid assignment in the condition.

Workaround:
If the assignment is moved outside the if clause, it works as expected.

        llvm::Value * c = dyn_cast<llvm::Value>(val)
	if (c) {


Reproducible: Always
Comment 1 Nathan Ridge CLA 2013-07-17 22:37:41 EDT
I get no errors or warnings with CDT 8.2 (Kepler).
Comment 2 Missing name CLA 2015-03-09 10:38:58 EDT
CDT (8.6 and before) has problems with llvm::dyn_cast template. dyn_cast is reported as unresolved symbol.
Comment 3 Nathan Ridge CLA 2015-03-09 11:39:58 EDT
(In reply to Missing name from comment #2)
> CDT (8.6 and before) has problems with llvm::dyn_cast template. dyn_cast is
> reported as unresolved symbol.

That sounds like a different issue - this bug is about a false-positive "possible assignment in condition" warning.

Could you file a new bug for the issue you're having, preferably with a complete testcase?
Comment 4 Nathan Ridge CLA 2016-12-29 18:26:05 EST
Closing per comment 1. Feel free to reopen if you're still seeing this issue.