https://bugs.llvm.org/show_bug.cgi?id=37086
Bug ID: 37086
Summary: scan-build doesn't detect unitianilized class members
in copy constructor
Product: clang
Version: 3.7
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Static Analyzer
Assignee: dcough...@apple.com
Reporter: marzec.wojci...@gmail.com
CC: llvm-bugs@lists.llvm.org
I wish to have a warning that some member in copy constructor/assignment
operator isn't initialized.
#include <iostream>
using namespace std;
struct B
{
int member;
B()
{
member =111;
}
B(B const & )
{}
B& operator=(B const & )
{ }
void hello() const
{
cout << "member value " << member << "\n";
}
};
struct D : B
{
D(){}
};
int main()
{
B* b1_ptr = new B;
b1_ptr->hello();
B* b2_ptr = new B(*b1_ptr);
b2_ptr->hello();
}
Above code gives me output:
member value 111
member value 0
Scan-build generaly warns about reading of unitialized variables but in this
case it is initialized with 0 by compiler however users forgets to do copy of
value and he expects to have the same object. So in this case the user should
be warn that he forgets to copy member value in copy constructor/assignment
operator.
Such case is handled by lint and it is a gap for unsecure code could you
implement such checking also in scan-build?
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs