Opened 12 years ago

Closed 4 years ago

Last modified 4 years ago

#4919 closed Patches (fixed)

gil_concept.hpp triggers self-assignment warnings

Reported by: gromer@… Owned by: Stefan Seefeld
Milestone: Boost 1.68.0 Component: gil USE GITHUB
Version: Boost 1.45.0 Severity: Problem
Keywords: Cc: mateusz@…

Description

boost/gil/gil_concept.hpp contains several instances of assigning a variable to itself. In context, this is perfectly safe (since the code should never actually be executed), but it nonetheless triggers gcc's -Wself-assign, cluttering the build output for those who have that flag set, and breaking the build for those who also set -Werror.

I am unable to suggest a fix for the instance in PointNDConcept, because the line in question ("point[0] = point[0];", line 276) appears to be checking properties that are not part of the concept as documented; I can find no documentation of the fact that models of PointNDConcept are expected to have an operator[], much less what the parameter and return types of that operator are.

The attached patch contains trivial fixes for the other instances, which I believe have no impact on correctness or performance.

Attachments (3)

selfassign.patch (770 bytes ) - added by gromer@… 12 years ago.
Partial fix for the bug
boost-gil-self-assignment-fix.patch (2.3 KB ) - added by Dean Michael Berris 10 years ago.
Updated documentation and self-assignments.
gil.patch (2.0 KB ) - added by Marshall Clow 10 years ago.
Revised GIL self-assignment patch

Download all attachments as: .zip

Change History (16)

by gromer@…, 12 years ago

Attachment: selfassign.patch added

Partial fix for the bug

comment:1 by Vicente Botet <vicente.botet@…>, 12 years ago

Type: BugsPatches

comment:2 by gromer@…, 12 years ago

Please note that the attached patch does not completely resolve the issue; as noted in the summary I do not know what the correct resolution is for the self-assignment in PointNDConcept, because either the code is incorrect or the documentation is incomplete, and I don't know which.

comment:3 by Dean Michael Berris, 10 years ago

Any updates on this? Can we remove the self-assignment check in the concept instead completely? There are other ways to test for assignable which doesn't involve self-assignment.

in reply to:  2 comment:4 by Dean Michael Berris, 10 years ago

Owner: changed from Hailin Jin to Marshall Clow

Replying to gromer@…:

Please note that the attached patch does not completely resolve the issue; as noted in the summary I do not know what the correct resolution is for the self-assignment in PointNDConcept, because either the code is incorrect or the documentation is incomplete, and I don't know which.

Okay, I had a look at this and it seems that PointNDConcept<T> does imply that it should be Regular<T>. This means it supports all the regular type requirements.

Because this is a concept check it means whatever is in the concept definition determines the requirements. I'm inclined to think that merely switching the assignment to:

value_type v = p[0];
p[0] = v;

Should fix the issue properly. I'll attach a new patch that should fix this.

comment:5 by Dean Michael Berris, 10 years ago

Also, as an addendum, the concept does require that the type T has a subscript operator, as this deals with axes of a Point. Subsequent Point*DConcept tests that depend on PointNDConcept where subscripting is required. In my patch I have updated the concept documentation to reflect this.

by Dean Michael Berris, 10 years ago

Updated documentation and self-assignments.

comment:6 by Dean Michael Berris, 10 years ago

Apologies for the delay. Marshall, would you mind having a look at the updated patch?

comment:7 by Marshall Clow, 10 years ago

I spoke to Lubomir, and he said:

"PointNDConcept is an N-dimensional point where each dimension may have a different type. Therefore it cannot have operator[]. So the documentation is correct and the line point[0] = point[0] should be removed."

by Marshall Clow, 10 years ago

Attachment: gil.patch added

Revised GIL self-assignment patch

comment:8 by Dean Michael Berris, 10 years ago

Okay, this looks and sounds good to me! Can we commit this change and perhaps get this to a release branch too? :)

comment:9 by Marshall Clow, 10 years ago

(In [82092]) Apply patch for Lubomir; Refs #4919

comment:10 by Dean Michael Berris, 9 years ago

Can we get an update on when [82092] will make it into a release? 1.54.0 still doesn't have this IIUC.

comment:11 by Mateusz Loskot, 6 years ago

Cc: mateusz@… added

comment:12 by Stefan Seefeld, 5 years ago

Owner: changed from Marshall Clow to Stefan Seefeld

comment:13 by Mateusz Loskot, 4 years ago

Milestone: To Be DeterminedBoost 1.68.0
Resolution: fixed
Status: newclosed
Last edited 4 years ago by Mateusz Loskot (previous) (diff)
Note: See TracTickets for help on using tickets.