Skip to content

Conversation

@marcosbento
Copy link
Contributor

@marcosbento marcosbento commented Dec 2, 2025

Description

An attempt to modernize the code base, by removing the use of the "old style" NonCopyable in favour of explicitly deleting copy/move ctor/assignment operators. Uses of OnlyMovable are also removed, in favour of explicitly deleted/defaulted copy/move ctor/assignment operators.

This follows the advice of the CppCoreGuidelines, which states = delete is preferred -- see the discussion here.

Important: Since downstream project use NonCopyable through transitive #include dependencies, the proposed changes effectively cause build failures -- i.e. older version of odc, fdb, gribjump, ... won't be able to build against versions of eckit with these changes!

Contributor Declaration

By opening this pull request, I affirm the following:

  • All authors agree to the Contributor License Agreement.
  • The code follows the project's coding standards.
  • I have performed self-review and added comments where needed.
  • I have added or updated tests to verify that my changes are effective and functional.
  • I have run all existing tests and confirmed they pass.

🌦️ >> Documentation << 🌦️
https://sites.ecmwf.int/docs/dev-section/eckit/pull-requests/PR-238

@codecov-commenter
Copy link

codecov-commenter commented Dec 2, 2025

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.24%. Comparing base (f8ad909) to head (da1ba2a).

Files with missing lines Patch % Lines
src/eckit/io/cluster/ClusterDisks.cc 0.00% 1 Missing ⚠️
src/eckit/runtime/Monitor.h 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #238      +/-   ##
===========================================
- Coverage    66.25%   66.24%   -0.01%     
===========================================
  Files         1131     1130       -1     
  Lines        57959    57955       -4     
  Branches      4394     4394              
===========================================
- Hits         38398    38394       -4     
  Misses       19561    19561              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@marcosbento marcosbento force-pushed the feature/deprecate_noncopyable branch 2 times, most recently from 38b7898 to 9c9402d Compare December 2, 2025 18:31
@wdeconinck
Copy link
Member

wdeconinck commented Dec 3, 2025

Compilation errors detected for ODC:
https://github.com/ecmwf/eckit/actions/runs/19869433903/job/56941583645?pr=238#step:3:2931

In file included from /opt/actions-runner/work/_work/eckit/eckit/src/odc/ODBAPISettings.cc:24:
/opt/actions-runner/work/_work/eckit/eckit/src/odc/ODBAPISettings.h:24:39: error: expected class name
24 | class ODBAPISettings : private eckit::NonCopyable {
   |                                       ^
1 error generated.

@marcosbento
Copy link
Contributor Author

Compilation errors detected for ODC: https://github.com/ecmwf/eckit/actions/runs/19869433903/job/56941583645?pr=238#step:3:2931

In file included from /opt/actions-runner/work/_work/eckit/eckit/src/odc/ODBAPISettings.cc:24:
/opt/actions-runner/work/_work/eckit/eckit/src/odc/ODBAPISettings.h:24:39: error: expected class name
24 | class ODBAPISettings : private eckit::NonCopyable {
   |                                       ^
1 error generated.

It seems that ODC, and maybe a few others, depend on NonCopyable through transitive #include dependencies (which have now disappeared).

I feel the best way to fix this is to create PRs on the failing downstream projects to introduce the needed #include.
Even better, and since we have to touch these sources anyway, would be to simply remove the use NonCopyable from those projects and avoid the deprecation warning.

@marcosbento
Copy link
Contributor Author

The downstream changes to fix ODC are at ecmwf/odc#48.

@simondsmart
Copy link
Contributor

Thanks. Have merged the changes in odc.

@marcosbento marcosbento force-pushed the feature/deprecate_noncopyable branch 3 times, most recently from 7573dbc to 57fcd34 Compare December 4, 2025 10:30
@marcosbento
Copy link
Contributor Author

Similar issues (e.g. transitive #include dependencies on NonCopyable) found in FDB are fixed and awaiting review: ecmwf/fdb#207

@marcosbento marcosbento force-pushed the feature/deprecate_noncopyable branch from 57fcd34 to 9a74806 Compare December 4, 2025 14:36
@marcosbento
Copy link
Contributor Author

Following a comment from @pmaciel, the non-copyable classes now follow the rule of 5 (https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#rc-five).

n.b. this means only that the classes that were updated, by removing inheritance of NonCopyable, have been made to follow this rule. It is likely that other classes in eckit do not strictly adhere to the rule of 5.

@marcosbento marcosbento force-pushed the feature/deprecate_noncopyable branch 2 times, most recently from e1137c4 to ec5f1a8 Compare December 4, 2025 14:55
@marcosbento
Copy link
Contributor Author

Similar issues (e.g. transitive #include dependencies on NonCopyable) found in GribJump are fixed and awaiting review: ecmwf/gribjump#79

@marcosbento marcosbento changed the title Deprecate NonCopyable in favour of explicitly deleted ctors [Breaking API!!!] Deprecate NonCopyable in favour of explicitly deleted ctors Dec 4, 2025
@Ozaq
Copy link
Member

Ozaq commented Dec 5, 2025

@marcosbento can you please create a eckit jira issue to track the items for 2.0?

@marcosbento marcosbento force-pushed the feature/deprecate_noncopyable branch from ec5f1a8 to c88daa1 Compare December 5, 2025 17:44
@wdeconinck
Copy link
Member

It is a good idea to identify all issues now and make fixes in all packages, but could we not also keep a deprecation so that existing packages can transition independently? I am thinking about being able to update eckit and eg perhaps multio in ifs-bundle (including older cycles ) without needing to update everything else. What would be required to achieve this?

@marcosbento
Copy link
Contributor Author

It is a good idea to identify all issues now and make fixes in all packages, but could we not also keep a deprecation so that existing packages can transition independently? I am thinking about being able to update eckit and eg perhaps multio in ifs-bundle (including older cycles ) without needing to update everything else. What would be required to achieve this?

@wdeconinck To deprecate NonCopyable in eckit was my original idea. I said to myself "this should be easy pickings!".

But removing the use of NonCopyable from eckit itself caused downstream CI failures, as these packages had transitive dependencies (e.g. they included some Factory.h, and then used NonCopyable because it was made available without actually including NonCopyable.h).

The only way to still allow downstream packages to compile, would be to leave the "unnecessary" #include ".../NonCopyable.h" in eckit itself. We could certainly leave these in, but I would argue that it goes against the spirit of deprecating NonCopyable. Removing them, regardless if we do it now or later, is a clear API breaking change.

So, for me, the mission (should we choose to accept it) is to remove all uses of NonCopyable from downstream packages; and leave this PR to be merged somewhere in the future, where we have a "major" version release of eckit. This way, the adoption of the new version of eckit by the downstream packages is a essentially no-op (at least regarding NonCopyable).

@marcosbento
Copy link
Contributor Author

@marcosbento can you please create a eckit jira issue to track the items for 2.0?

Done! See ECKIT-645...

@Ozaq
Copy link
Member

Ozaq commented Dec 9, 2025

It is a good idea to identify all issues now and make fixes in all packages, but could we not also keep a deprecation so that existing packages can transition independently? I am thinking about being able to update eckit and eg perhaps multio in ifs-bundle (including older cycles ) without needing to update everything else. What would be required to achieve this?

This is, given my understanding, the goal.

We want to remove use of 'non-copyable' in as many projects as we can without requiring additional coordination, then remove its use in eckit. Then we can declare it deprecated.

@simondsmart
Copy link
Contributor

Agreed that this is the goal. Removing this class should be one of the items on the list of breaking API changes for eckit 2.0.0, due in 2026

@wdeconinck
Copy link
Member

I understand that relying on transitive includes is a bug and not a deprecation issue in e.g. odc and therefore it is indeed a hotfix to odc to make that problem disappear. A hotfix is in those projects is warranted I think for this, for the case where eckit makes a release before a SR including odc.

@marcosbento marcosbento force-pushed the feature/deprecate_noncopyable branch 2 times, most recently from c112dcb to f25bae1 Compare December 16, 2025 10:53
@marcosbento marcosbento changed the title [Breaking API!!!] Deprecate NonCopyable in favour of explicitly deleted ctors [Breaking API!!!] Replace NonCopyable uses with explicitly deleted ctors Dec 16, 2025
@marcosbento marcosbento changed the title [Breaking API!!!] Replace NonCopyable uses with explicitly deleted ctors Replace NonCopyable uses with explicitly deleted ctors Dec 16, 2025
@pmaciel
Copy link
Member

pmaciel commented Dec 16, 2025

Can we declare NonCopyable deprecated?

@marcosbento
Copy link
Contributor Author

Can we declare NonCopyable deprecated?

@Ozaq suggested to remove the [[deprecated]] attribute to make the PR more focused, i.e. the focus now is "simply" to remove the uses of NonCopyable from eckit itself.

Once this PR is accepted, I'm glad to create a standalone PR just to add the [[deprecated]].

@danovaro
Copy link
Member

danovaro commented Jan 9, 2026

Similar issues (e.g. transitive #include dependencies on NonCopyable) found in FDB are fixed and awaiting review: ecmwf/fdb#207

merged

@marcosbento marcosbento force-pushed the feature/deprecate_noncopyable branch from f25bae1 to 4a3b465 Compare January 12, 2026 13:41
@marcosbento
Copy link
Contributor Author

We now have a ✅ on the build!

@Ozaq Ozaq force-pushed the feature/deprecate_noncopyable branch from 4a3b465 to 023105f Compare January 20, 2026 08:51
@Ozaq Ozaq marked this pull request as ready for review January 20, 2026 09:02
@Ozaq Ozaq force-pushed the feature/deprecate_noncopyable branch 3 times, most recently from 23ffbbc to 4ce5bcd Compare January 20, 2026 11:03
@Ozaq Ozaq force-pushed the feature/deprecate_noncopyable branch from 4ce5bcd to 1841804 Compare January 28, 2026 08:48
Replaces NonCopyable uses with explicitly deleted ctors and  replace
uses of OnlyMovable.
@marcosbento marcosbento force-pushed the feature/deprecate_noncopyable branch from 1841804 to da1ba2a Compare January 28, 2026 16:07
@Ozaq Ozaq merged commit 842765c into develop Jan 29, 2026
526 of 529 checks passed
@Ozaq Ozaq deleted the feature/deprecate_noncopyable branch January 29, 2026 14:24
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.

8 participants