<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - static analyzer makes incorrect assumption of dynamic type"
href="https://bugs.llvm.org/show_bug.cgi?id=42423">42423</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>static analyzer makes incorrect assumption of dynamic type
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>martongabesz@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=22153" name="attach_22153" title="reproducer">attachment 22153</a> <a href="attachment.cgi?id=22153&action=edit" title="reproducer">[details]</a></span>
reproducer
The following lit test fails, but it should pass.
1 // RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu \
2 // RUN: -analyzer-checker=core,debug.ExprInspection \
3 // RUN: -verify %s
4
5 void clang_analyzer_eval(int);
6
7 struct B {
8 virtual int f(int x) { return 0; }
9 };
10
11 struct D : B {
12 virtual int f(int x) { return 1; }
13 };
14
15 void test_virt2(B* obj) {
16 // The dynamic type is known.
17 clang_analyzer_eval(B().f(1)); // expected-warning{{FALSE}}
18 clang_analyzer_eval(D().f(1)); // expected-warning{{TRUE}}
19 // We cannot decide about the dynamic type.
20 clang_analyzer_eval(obj->f(1)); // expected-warning{{UNKNOWN}}
22 }
This is the error:
Command Output (stderr):
--
error: 'warning' diagnostics seen but not expected:
File
/home/egbomrt/WORK/llvm5/git/llvm-project/clang/test/Analysis/virtual_func_bug.cpp
Line 20: FALSE
1 error generated.
So, it seems like there is a state split at line 20. Maybe the analyzer assumes
that the `obj` has a concrete type `B` at one branch and at the other branch it
is unknown?</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>