Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 362603 - "possible assignment in condition" invalid for correct assignment
Summary: "possible assignment in condition" invalid for correct assignment
Status: RESOLVED WORKSFORME
Alias: None
Product: CDT
Classification: Tools
Component: cdt-codan (show other bugs)
Version: 8.0   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: CDT Codan Inbox CLA
QA Contact: Elena Laskavaia CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-01 17:13 EDT by Martin Nowack CLA
Modified: 2016-12-29 18:26 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.