Date_Time : Error in time_duration.hpp

Hello, I have encountered some errors in Boost, while running some static analyzer tool. It is reported in boost/date_time/time_duration.hpp The error is: *boost::date_time::time_duration has user-written copy constructor but no corresponding user-written assignment operator.* *Is it valid to apply the following patch.* diff -Naur a/boost/date_time/time_duration.hpp b/boost/date_time/time_duration.hpp --- a/boost/date_time/time_duration.hpp 2012-10-11 00:35:03.000000000 +0530 +++ b/boost/date_time/time_duration.hpp 2012-11-26 18:29:16.000000000 +0530 @@ -251,6 +251,9 @@ return ticks_; } + private: + time_duration &operator=(const time_duration<T, rep_type>& other); + protected: explicit time_duration(impl_type in) : ticks_(in) {} impl_type ticks_; * * -- Regards, Gaurav

On Wed, Nov 28, 2012 at 3:13 PM, GAURAV GUPTA <ya1gaurav@gmail.com> wrote:
Hello,
I have encountered some errors in Boost, while running some static analyzer tool.
It is reported in boost/date_time/time_duration.hpp
The error is:
*boost::date_time::time_duration has user-written copy constructor but no corresponding user-written assignment operator.*
*Is it valid to apply the following patch.*
The patch is not valid since it disables assignment. The compiler-generated assignment is suitable, the copy constructor probably doesn't have to be user-defined as well. There is a comment that it is required by dividable<> but I can't see where it's used.

hello,
The patch is not valid since it disables assignment. The compiler-generated assignment is suitable, the copy constructor probably doesn't have to be user-defined as well.
But the tool I am using is reporting me the above error. If i remove the copy constructor, then it will report error for *Missing copy* error also. So how can I fix it? On Wed, Nov 28, 2012 at 4:59 PM, Andrey Semashev <andrey.semashev@gmail.com>wrote:
On Wed, Nov 28, 2012 at 3:13 PM, GAURAV GUPTA <ya1gaurav@gmail.com> wrote:
Hello,
I have encountered some errors in Boost, while running some static analyzer tool.
It is reported in boost/date_time/time_duration.hpp
The error is:
*boost::date_time::time_duration has user-written copy constructor but no corresponding user-written assignment operator.*
*Is it valid to apply the following patch.*
The patch is not valid since it disables assignment. The compiler-generated assignment is suitable, the copy constructor probably doesn't have to be user-defined as well. There is a comment that it is required by dividable<> but I can't see where it's used.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
-- Regards, Gaurav

On Wed, Nov 28, 2012 at 3:42 PM, GAURAV GUPTA <ya1gaurav@gmail.com> wrote:
hello,
The patch is not valid since it disables assignment. The compiler-generated assignment is suitable, the copy constructor probably doesn't have to be user-defined as well.
But the tool I am using is reporting me the above error. If i remove the copy constructor, then it will report error for *Missing copy* error also. So how can I fix it?
You can explicitly define the assignment operator. But the reported error is bogus in this case. PS: Please, don't top-post.

On 28 November 2012 11:42, GAURAV GUPTA <ya1gaurav@gmail.com> wrote:
hello,
The patch is not valid since it disables assignment. The compiler-generated assignment is suitable, the copy constructor probably doesn't have to be user-defined as well.
But the tool I am using is reporting me the above error. If i remove the copy constructor, then it will report error for *Missing copy* error also. So how can I fix it? <http://lists.boost.org/mailman/listinfo.cgi/boost>
You haven't said what tool you are using. Regardless, false positive warnings/errors are not uncommon. Teach or fix your analyzer to be quiet about it, disable the warning, report it to the analyzer's manufacturer. If you use clang analyzer, check the False Positives http://clang-analyzer.llvm.org/ Best regards, -- Mateusz Loskot, http://mateusz.loskot.net

On Wed, Nov 28, 2012 at 5:18 PM, Mateusz Loskot <mateusz@loskot.net> wrote:
On 28 November 2012 11:42, GAURAV GUPTA <ya1gaurav@gmail.com> wrote:
hello,
The patch is not valid since it disables assignment. The compiler-generated assignment is suitable, the copy constructor probably doesn't have to be user-defined as well.
But the tool I am using is reporting me the above error. If i remove the copy constructor, then it will report error for *Missing copy* error also. So how can I fix it? <http://lists.boost.org/mailman/listinfo.cgi/boost>
You haven't said what tool you are using.
We are using the Coverity Prevent tool.
Regardless, false positive warnings/errors are not uncommon. Teach or fix your analyzer to be quiet about it, disable the warning, report it to the analyzer's manufacturer.
If you use clang analyzer, check the False Positives http://clang-analyzer.llvm.org/
Best regards, -- Mateusz Loskot, http://mateusz.loskot.net
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
-- Regards, Gaurav
participants (3)
-
Andrey Semashev
-
GAURAV GUPTA
-
Mateusz Loskot