Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test for deleted construction-copyable / copyable code #1528

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

s-trinh
Copy link
Contributor

@s-trinh s-trinh commented Dec 22, 2024

Some classes seem to have deleted "copy constructor" / "copy operator", see: afc5bc9

The following code build correctly but will segfault at runtime:

#include <visp3/core/vpConfig.h>
#include <visp3/core/vpIoTools.h>
#include <visp3/mbt/vpMbGenericTracker.h>

static std::string ipath = vpIoTools::getViSPImagesDataPath();

int main()
{
  const std::string cao_filename =
    vpIoTools::createFilePath(ipath, "mbt/cube_and_cylinder.cao");
  vpMbGenericTracker tracker;
  const bool verbose = true;
  tracker.loadModel(cao_filename, verbose);

  std::list<vpMbtDistanceCylinder *> cylinders;
  tracker.getLcylinder(cylinders);
  std::cout << "cylinders=" << cylinders.size() << std::endl;

  // vpMbtDistanceCylinder cylinder(*(cylinders.front()));
  for (auto cylinder : cylinders) {
    vpMbtDistanceCylinder cy = *cylinder;
    // cy.buildFrom(*cylinder->p1, *cylinder->p2, cylinder->radius);
    // vpMbtDistanceCylinder cy2 = cy;
    std::cout << cylinder->p1->get_oX() << std::endl;
  }

  return EXIT_SUCCESS;
}

This pull request tries to see if the library still builds with =delete copy constructor / operator.


If possible, adding "non construction-copyable" / "non copyable" function member for these specific classes would produce build failure and would directly warn the user these classes cannot be copied:

#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
  vpMbtDistanceCylinder(const vpMbtDistanceCylinder &) = delete; // non construction-copyable
  vpMbtDistanceCylinder &operator=(const vpMbtDistanceCylinder &) = delete; // non copyable
#endif

Copy link

codecov bot commented Dec 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 53.82%. Comparing base (bc9a67e) to head (956aa51).
Report is 4 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1528   +/-   ##
=======================================
  Coverage   53.82%   53.82%           
=======================================
  Files         441      441           
  Lines       53859    53859           
=======================================
  Hits        28991    28991           
  Misses      24868    24868           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant