Opened 9 years ago

Closed 9 years ago

Last modified 6 years ago

#8531 closed Bugs (fixed)

[Coverity] boost/function/function_template.hpp: spurious warnings

Reported by: Dan Kegel <dank@…> Owned by: Marshall Clow
Milestone: To Be Determined Component: function
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description

This was found in an older release, but is still present in trunk.

Coverity complains

(1) Event pointless_expression: The expression "false /* mpl_::bool_<false>::value */ && false /* mpl_::bool_<false>::value */" does not
   accomplish anything because it evaluates to either of its identical operands, "false /* mpl_::bool_<false>::value */". Did you intend the
   operands to be different?

938  if (boost::has_trivial_copy_constructor<Functor>::value &&
939      boost::has_trivial_destructor<Functor>::value &&
940      detail::function::function_allows_small_object_optimization<Functor>::value)

And a similar error near line 973.

It complains very loudly indeed; every use of assign_to generates this warning. Until Coverity sprouts a suppression file feature like Valgrind has, putting an annotation in the source is the way to make Coverity shut up about this. The attached patch does that.

To reproduce (assuming you have a Coverity license, and bjam installed in ~/local/bin):

cd ~/boost-trunk/libs/functions/tests
PATH=/opt/coverity/cov-analysis-linux64-6.5.1/bin:$HOME/local/bin:$PATH
cov-configure --gcc
rm -rf covlog
mkdir -p covlog
cov-build --dir covlog bjam
cov-analyze --dir covlog
cov-format-errors --dir covlog

Then look at covlog/c/output/errors/index.html in a web browser. If you see a bunch of errors like

CONSTANT_EXPRESSION_RESULT .../boost/function/function_template.hpp

then you have the problem. The attached patch makes those warnings go away (and reduces the number of warnings in this test from 169 to 79).

Attachments (1)

boost-function2.patch (1.1 KB ) - added by Dan Kegel <dank@…> 9 years ago.
Draft patch to silence spurious warnings

Download all attachments as: .zip

Change History (7)

by Dan Kegel <dank@…>, 9 years ago

Attachment: boost-function2.patch added

Draft patch to silence spurious warnings

comment:1 by Jeffrey Walton <noloader@…>, 9 years ago

To reproduce (assuming you have a Coverity license...)

Coverity offers its scanning service gratis to open and free projects. Boost can sign up for an account at http://scan.coverity.com/projects.

comment:2 by Marshall Clow, 9 years ago

Owner: changed from Douglas Gregor to Marshall Clow
Status: newassigned

comment:3 by Marshall Clow, 9 years ago

Fixed on develop in commit 9f06e35e8d8e886b87e7f3ddf846e59a2c282613

Will close when merged to master.

comment:4 by Marshall Clow, 9 years ago

Resolution: fixed
Status: assignedclosed

Merged to master in commit a80ac7f5c560911ebedabafe4016df57a9cf3a63

comment:5 by James E. King, III <jim.king@…>, 6 years ago

Hi, this was merged to master however the ticket was not updated with a release milestone or marked as closed.

comment:6 by James E. King, III <jim.king@…>, 6 years ago

Note: See TracTickets for help on using tickets.