Drop template-id from ctor/dtor names in numeric/ (GCC 14/15 -Werror=template-id-cdtor) - #723
Merged
roccomoretti merged 3 commits intoJul 3, 2026
Conversation
lyskov
approved these changes
Jun 26, 2026
GCC 15 enforces -Werror=template-id-cdtor: a class template may not name its own constructors or destructors with explicit template arguments (the injected-class-name must be used without <...>). MathVector and MathMatrix declared several ctors and their dtor as e.g. 'MathVector< T>()' and '~MathVector< T>()', which fails to compile under GCC 15 in C++20 mode and broke the debug build before it reached any core/ code. Drop the '< T>' so these match the injected-class-name form already used by the copy constructors in the same classes. No semantic change.
Same -Werror=template-id-cdtor issue as MathVector/MathMatrix: the default constructor named itself 'OneDHistogram<key1>()' instead of using the injected-class-name. This one only surfaces when something instantiates the ctor (a unit test does), so it slipped past a library-only build and is what broke CI on the previous version of this fix.
lyskov-ai
force-pushed
the
fix/numeric-gcc15-template-id-cdtor
branch
from
July 1, 2026 00:21
5f88382 to
631830c
Compare
Member
|
Looks like this needs beautification: https://b3.graylab.jhu.edu/test/915440 |
Running tools/python_cc_reader/beautify_changed_files_in_branch.py over the files touched by this branch restores project-standard formatting that the template-id edits had left off: member-initializer lists in MathVector/ MathMatrix are re-indented one level under their constructors (matching the copy constructors in the same classes). Incidentally normalizes pre-existing style in OneDHistogram.hh (namespace brace spacing, data-member indentation) so the beautify check passes on all files in this branch's diff. Whitespace-only; no semantic change.
lyskov-ai
added a commit
to lyskov-ai/rosetta
that referenced
this pull request
Jul 2, 2026
This branch carries the same numeric/ template-id ctor/dtor fix as RosettaCommons#723; run tools/python_cc_reader/beautify_changed_files_in_branch.py over the changed files to restore project-standard formatting the template-id edits had left off: member-initializer lists in MathVector/MathMatrix re-indented one level under their constructors, plus incidental namespace/data-member normalization in OneDHistogram.hh so the beautify check passes. Whitespace-only; no semantic change.
roccomoretti
approved these changes
Jul 3, 2026
lyskov
pushed a commit
that referenced
this pull request
Jul 9, 2026
…le cleanup (#728) ## Summary This machine has GCC 12 through GCC 16 (16 is an experimental trunk build) installed side by side. A survey of the debug library build under each version found: - **GCC 12, GCC 13**: build cleanly out of the box. - **GCC 14, GCC 15**: need the `template-id-cdtor` fix in #723. - **GCC 16**: needs #723's fix *plus* the changes in this PR. Building under GCC 16 (with #723's fix applied) surfaced 16 unique `-Werror` sites — mostly `-Wunused-but-set-variable`, plus two `-Wmaybe-uninitialized` cases (one of which is a real bug): 1. **Real bug** — `core/chemical/CacheableResidueTypeSets.cc`: the copy constructor initialized its base class with `CacheableData(*this)` instead of `CacheableData(other)`, reading from the not-yet-constructed destination object rather than the fully-constructed source. Harmless today only because `CacheableData` has no data members of its own; still wrong and exactly what GCC 16 is right to flag. 2. **False-positive trigger** — `protocols/simple_moves/MissingDensityToJumpMover.cc`: the default constructor called `MissingDensityToJumpMover::get_name()` (a qualified call through `*this`, mid-construction) to build an argument for the `Mover` base class. `get_name()` just returns a string literal, so it's passed directly instead — avoids the pattern rather than working around a compiler quirk. 3. **Dead loop counters** (13 sites across 9 files) — variables incremented alongside a real loop iterator but never read anywhere: `EnergyGraph.hh` (`iilag`, 2 of 4 occurrences — the other two are real array indices and are untouched), `PDBInfo.cc` (`idx`, x2), `mmtf_writer.cc` (`chainIndex`, `modelIndex`), `md.cc` (`imap`), `StructureDataFactory.cc` (`cur_chain`), `FoldArchitectMover.cc` (`count`), `pose_mod.hh` (`current_pos`), `DistanceScoreMover.cc` (`ct_peaks`), `StructureDependentPeakCalibrator.cc` (`pose_ct`). No behavior change — removed the tracking, left the actual iteration logic untouched. 4. **Deliberately-unused, kept** — `SapConstraintHelper.cc`'s `offset` is tracked "for symmetry" per an existing comment even though never read. Rather than removing it against that stated intent, added an explicit `(void)offset;` cast to satisfy the warning.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GCC 14+ enforces
-Werror=template-id-cdtor: a class template may not name its own constructors or destructors with explicit template arguments — the injected-class-name must be used without<...>.numeric/MathVector.hh,numeric/MathMatrix.hh, andnumeric/histograms/OneDHistogram.hhdeclared constructors (and, for the first two, the destructor) in the disallowed form, e.g.:Under GCC 14/15 in C++20 mode this fails to compile (
error: template-id not allowed for constructor/destructor in C++20). Thenumeric/occurrences broke the plain library debug build before it could even reachbasic/orcore/. TheOneDHistogram.hhoccurrence is more subtle: its default constructor is only instantiated by a unit test (numeric/histograms/OneDHistogram.cxxtest.hh), not by any library code, so it slipped past a library-only build and only surfaced when building/running the unit test suite — this is what broke CI on the previous version of this PR.This drops the
< T>/<key1>from the constructor and destructor declarator-ids, making them consistent with the copy constructors in the same classes, which already use the correct injected-class-name form. Return types, operators, andnewexpressions that legitimately use the templated name are untouched. Pure syntactic correction, no semantic change.Verified with a clean
mode=debuglibrary build andmode=debug cat=testunit-test build under GCC 15 (this machine's default), plus a full library build under GCC 14 — both fully green. A targeted scan ofsource/src,source/test, andsource/src/develfor the same declaration pattern turned up no other occurrences.Relationship to existing GCC 15 PRs (#555, #556)
This is not the first attempt at the GCC 15 build. Two earlier community PRs are still open and overlap with this one:
core/scoring/lkball/LK_DomeEnergy.cc,protocols/forge/remodel/RemodelGlobalFrame.cc,utility/options/VectorOption_T_.hh, two unit tests, andtools/build/basic.settings— none of which have this same template-id-cdtor pattern currently (checked directly), so those are addressing separate GCC 15 issues.Because #555 already lands the same fix, #723 is largely redundant with the
numeric/slice of that effort. It's offered as a minimal, narrowly-scoped version of just thetemplate-id-cdtorcorrection in case it's useful to merge the build-blocking part independently; otherwise #555 (combined with #556, per its author's note) supersedes it. Closing this in favor of #555 + #556 is fine if the maintainers prefer to consolidate the GCC 15 work.Note on diff size
This is a small change (three files, ~18 lines) — below the usual bundling threshold — but it is the complete fix for this pattern across the codebase: a scan of
source/src,source/test, andsource/src/develfound no other occurrences of a class template naming its own constructor/destructor with a template-id. Kept narrowly scoped to this one toolchain-compatibility pattern.