Skip to content

Conversation

@SpatLyu
Copy link
Contributor

@SpatLyu SpatLyu commented Jan 12, 2026

This PR adds a virtual destructor to the ProgressPrinter abstract base class to resolve a Clang warning observed on macOS:

clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Volumes/Builds/templates/cran-build/big-sur-arm64/Rlib/4.6/Rcpp/include' -I'/Volumes/Builds/templates/cran-build/big-sur-arm64/Rlib/4.6/RcppThread/include' -I'/Volumes/Builds/templates/cran-build/big-sur-arm64/Rlib/4.6/RcppArmadillo/include' -I/opt/R/arm64/include   -DARMA_USE_CURRENT -fPIC  -falign-functions=64 -Wall -g -O2   -c SCPCM4Grid.cpp -o SCPCM4Grid.o
In file included from PatternCausality.cpp:1:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/c++/v1/vector:321:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/c++/v1/__format/formatter_bool.h:17:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/c++/v1/__format/concepts.h:17:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/c++/v1/__format/format_parse_context.h:16:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/c++/v1/string_view:1059:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/c++/v1/algorithm:1778:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/c++/v1/__algorithm/inplace_merge.h:28:
/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/c++/v1/__memory/unique_ptr.h:68:5: warning: delete called on non-final 'RcppThread::ProgressBar' that has virtual functions but non-virtual destructor [-Wdelete-non-abstract-non-virtual-dtor]
   68 |     delete __ptr;
      |     ^
/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/c++/v1/__memory/unique_ptr.h:300:7: note: in instantiation of member function 'std::default_delete::operator()' requested here
  300 |       __ptr_.second()(__tmp);
      |       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/c++/v1/__memory/unique_ptr.h:266:75: note: in instantiation of member function 'std::unique_ptr::reset' requested here
  266 |   _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); }
      |                                                                           ^
PatternCausality.cpp:754:44: note: in instantiation of member function 'std::unique_ptr::~unique_ptr' requested here
  754 |   std::unique_ptr bar;
      |         

Since ProgressPrinter declares a pure virtual function (printProgress()), it is used polymorphically. Deleting derived objects through a base-class pointer (e.g., via std::unique_ptr<ProgressPrinter>) without a virtual destructor results in undefined behavior and triggers this warning.

Adding

virtual ~ProgressPrinter() = default;

ensures correct destruction of derived instances. Because ProgressPrinter is already a polymorphic type, this change does not introduce any additional runtime overhead.

@tnagler
Copy link
Owner

tnagler commented Jan 12, 2026

Thanks!

@tnagler tnagler merged commit d335d75 into tnagler:main Jan 12, 2026
0 of 5 checks passed
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.

2 participants