Opened 10 years ago

Closed 10 years ago

#7746 closed Bugs (invalid)

Copy without assign problem in find_iterator.hpp

Reported by: Gaurav Gupta <g.gupta@…> Owned by: Marshall Clow
Milestone: To Be Determined Component: algorithm
Version: Boost 1.52.0 Severity: Problem
Keywords: Cc: yogen.saini@…

Description

I have encountered some errors in Boost, while running some static analyzer tool.

It is reported in boost/algorithm/string/find_iterator.hpp

The error is: find_iterator and split_iterator classes has user-written copy constructor but no corresponding user-written assignment operator.

I have attached a patch herewith. Is it valid to apply this fix?

Attachments (1)

find_iterator.hpp_patch (660 bytes ) - added by Gaurav Gupta <g.gupta@…> 10 years ago.
Proposed patch

Download all attachments as: .zip

Change History (6)

by Gaurav Gupta <g.gupta@…>, 10 years ago

Attachment: find_iterator.hpp_patch added

Proposed patch

comment:1 by Marshall Clow, 10 years ago

Do you have a sample program that fails to compile/misbehaves because there is no explicit assignment operator?

comment:2 by Marshall Clow, 10 years ago

(In [81615]) Added tests for assignment of Boost::find_iterator and split_iterator; Refs #7746

comment:3 by Gaurav Gupta <g.gupta@…>, 10 years ago

Thanks for adding tests. I tried running my static analyzer tool (Coverity Prevent) on this test file and the tool is reporting the same errors. The patch I attached is no doubt, not a solution of this problem. So I want your feedback, whether this error should be fixed or assignment operator is left intentionally? If it is a bug, do we need to define a user-written assignment operator for it?

comment:4 by Marshall Clow, 10 years ago

It doesn't appear to me that this is a bug. The compiler-generated assignment operator does the right thing.

The only reason (that I can tell) for the user-defined copy constructor is to call a particular base-class constructor.

I've never used Coverity on C++ code, but when I used it on C code (3 years ago), it had a very high false positive rate.

comment:5 by Marshall Clow, 10 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.