I suggest you ...

Allow Lint to see that constructor takes ownership of memory.

Lint sees that ownership of allocated memory is taken by a constructor if the owning object isn't "new'd". But if the owning object is "new'd", then Lint does not understand this. See the example below, which works in the online demo.

This was discussed in this thread, as well as several others:
http://www.gimpel.com/Discussion.cfm?ThreadID=808

//lint -e438, -e529, -e1502, -e1712, -e1788, -e714
#include <memory>

struct A { A(char *){}; };
void g( )
{
// This results in a 429 warning.
char * ptr1 = (char *) malloc(10);
A *a1 = new A(ptr1);

// This does not result in a 429 warning.
char * ptr2 = (char *) malloc(10);
A a2(ptr2);
}

16 votes
Vote
Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
You have left! (?) (thinking…)
Carl shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

0 comments

Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
Submitting...

Feedback and Knowledge Base