Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000228Rosetta[All Projects] Bad Codingpublic2013-03-22 17:022013-11-18 16:49
Reporterrmoretti 
Assigned Tormoretti 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product VersionTrunk 
Fixed in Version 
Summary0000228: ScoreFunction cloning
DescriptionBecause of the distinction between ScoreFunction and SymmetricScoreFunction (as well as the other ScoreFunction subclasses), you should never use the copy constructor of ScoreFunction() to make a new copy of a ScoreFunction. Use scorefxn.clone() instead.

Note there's no drawback to this, even if you know that you have a true ScoreFunction.
Steps To ReproduceTo find potential violators:

egrep -R 'new[[:space:]]*ScoreFunction[[:space:]]*\([^)]' rosetta/rosetta_source/src

Additional InformationCommand currently finds 66 instances. Some are valid, like the 7 in will and neil's apps/pilot directories, which are explicitly intended to take a symmetric scorefunction and asymmetrize it. Most of the rest are probably latent bugs.

They'll need to be checked manually, though.
TagsNo tags attached.
Application(s) Affectedmany
Command Line Usedn/a
Developer Options
Fixed in SVN Version36c2c81b7794e1f70a9520da778b3239dc3757a5
Attached Files

- Relationships

-  Notes
(0000210)
smlewis (Administrator)
2013-03-22 17:25

Is there a future in privatizing the copy operator to force people to use clone? I am guessing not from your notes.
(0000211)
Sergey (Administrator)
2013-03-22 17:28

As Steven suggested: How about declare copy constructor and copy operator as private and never define them? That way it will be impossible to copy without clone.
(0000212)
rmoretti (Attentive Developer)
2013-03-24 19:03

If we provide a new method for those few people who explicitly want to convert a scorefunction to the base class (with a name that makes it clear that's what they're doing), I think making the copy constructor private might work.

- Issue History
Date Modified Username Field Change
2013-03-22 17:02 rmoretti New Issue
2013-03-22 17:25 smlewis Note Added: 0000210
2013-03-22 17:28 Sergey Note Added: 0000211
2013-03-24 19:03 rmoretti Note Added: 0000212
2013-11-18 16:49 rmoretti Fixed in SVN Version => 36c2c81b7794e1f70a9520da778b3239dc3757a5
2013-11-18 16:49 rmoretti Status new => resolved
2013-11-18 16:49 rmoretti Resolution open => fixed
2013-11-18 16:49 rmoretti Assigned To => rmoretti


Copyright © 2000 - 2012 MantisBT Group
Powered by Mantis Bugtracker