Skip to content

[glass] Fix compilation errors from C++23 Clang #8008

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

Conversation

calcmogul
Copy link
Member

@calcmogul calcmogul commented Jun 5, 2025

In file included from /Users/runner/work/allwpilib/allwpilib/glass/src/libnt/native/cpp/NTMechanism2D.cpp:5:
In file included from /Users/runner/work/allwpilib/allwpilib/glass/src/libnt/native/include/glass/networktables/NTMechanism2D.h:7:
In file included from /Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/memory:898:
In file included from /Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/__memory/shared_ptr.h:31:
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/__memory/unique_ptr.h:66:19: error: invalid application of 'sizeof' to an incomplete type '(anonymous namespace)::NTMechanismObjectModel'
    static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type");
                  ^~~~~~~~~~~
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/__memory/unique_ptr.h:300:7: note: in instantiation of member function 'std::default_delete<(anonymous namespace)::NTMechanismObjectModel>::operator()' requested here
      __ptr_.second()(__tmp);
      ^
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/__memory/unique_ptr.h:266:75: note: in instantiation of member function 'std::unique_ptr<(anonymous namespace)::NTMechanismObjectModel>::reset' requested here
  _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); }
                                                                          ^
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/__memory/construct_at.h:69:13: note: in instantiation of member function 'std::unique_ptr<(anonymous namespace)::NTMechanismObjectModel>::~unique_ptr' requested here
    __loc->~_Tp();
            ^
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/__memory/construct_at.h:104:10: note: in instantiation of function template specialization 'std::__destroy_at<std::unique_ptr<(anonymous namespace)::NTMechanismObjectModel>, 0>' requested here
    std::__destroy_at(__loc);
         ^
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/__memory/allocator_traits.h:323:16: note: in instantiation of function template specialization 'std::destroy_at<std::unique_ptr<(anonymous namespace)::NTMechanismObjectModel>, 0>' requested here
        _VSTD::destroy_at(__p);
               ^
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/vector:944:25: note: in instantiation of function template specialization 'std::allocator_traits<std::allocator<std::unique_ptr<(anonymous namespace)::NTMechanismObjectModel>>>::destroy<std::unique_ptr<(anonymous namespace)::NTMechanismObjectModel>, void, void>' requested here
        __alloc_traits::destroy(__alloc(), std::__to_address(--__soon_to_be_end));
                        ^
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/vector:938:29: note: in instantiation of member function 'std::vector<std::unique_ptr<(anonymous namespace)::NTMechanismObjectModel>>::__base_destruct_at_end' requested here
  void __clear() _NOEXCEPT {__base_destruct_at_end(this->__begin_);}
                            ^
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/vector:489:20: note: in instantiation of member function 'std::vector<std::unique_ptr<(anonymous namespace)::NTMechanismObjectModel>>::__clear' requested here
            __vec_.__clear();
                   ^
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/vector:500:67: note: in instantiation of member function 'std::vector<std::unique_ptr<(anonymous namespace)::NTMechanismObjectModel>>::__destroy_vector::operator()' requested here
  _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~vector() { __destroy_vector(*this)(); }
                                                                  ^
/Users/runner/work/allwpilib/allwpilib/glass/src/libnt/native/cpp/NTMechanism2D.cpp:39:3: note: in instantiation of member function 'std::vector<std::unique_ptr<(anonymous namespace)::NTMechanismObjectModel>>::~vector' requested here
  NTMechanismGroupImpl(nt::NetworkTableInstance inst, std::string_view path,
  ^
/Users/runner/work/allwpilib/allwpilib/glass/src/libnt/native/cpp/NTMechanism2D.cpp:35:7: note: forward declaration of '(anonymous namespace)::NTMechanismObjectModel'
class NTMechanismObjectModel;
      ^

Explicitly declaring NTMechanismObjectModel's destructor fixes this specific error, but I get errors for RootModel from other .cpp files like StandardNetworkTables.cpp as well.

In file included from /home/tav/frc/wpilib/allwpilib/glass/src/libnt/native/cpp/StandardNetworkTables.cpp:5:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/memory:80:
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/bits/unique_ptr.h:91:16: error: invalid application of 'sizeof' to an incomplete type 'glass::NTMechanism2DModel::RootModel'
   91 |         static_assert(sizeof(_Tp)>0,
      |                       ^~~~~~~~~~~
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/bits/unique_ptr.h:399:4: note: in instantiation of member function 'std::default_delete<glass::NTMechanism2DModel::RootModel>::operator()' requested here
  399 |           get_deleter()(std::move(__ptr));
      |           ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/bits/stl_construct.h:88:15: note: in instantiation of member function 'std::unique_ptr<glass::NTMechanism2DModel::RootModel>::~unique_ptr' requested here
   88 |         __location->~_Tp();
      |                      ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/bits/stl_construct.h:164:12: note: in instantiation of function template specialization 'std::destroy_at<std::unique_ptr<glass::NTMechanism2DModel::RootModel>>' requested here
  164 |       std::destroy_at(__pointer);
      |            ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/bits/stl_construct.h:212:9: note: in instantiation of function template specialization 'std::_Destroy<std::unique_ptr<glass::NTMechanism2DModel::RootModel>>' requested here
  212 |           std::_Destroy(std::__addressof(*__first));
      |                ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/bits/alloc_traits.h:1045:12: note: in instantiation of function template specialization 'std::_Destroy<std::unique_ptr<glass::NTMechanism2DModel::RootModel> *>' requested here
 1045 |       std::_Destroy(__first, __last);
      |            ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../include/c++/15.1.1/bits/stl_vector.h:802:7: note: in instantiation of function template specialization 'std::_Destroy<std::unique_ptr<glass::NTMechanism2DModel::RootModel> *, std::unique_ptr<glass::NTMechanism2DModel::RootModel>>' requested here
  802 |         std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
      |              ^
/home/tav/frc/wpilib/allwpilib/glass/src/libnt/native/include/glass/networktables/NTMechanism2D.h:29:3: note: in instantiation of member function 'std::vector<std::unique_ptr<glass::NTMechanism2DModel::RootModel>>::~vector' requested here
   29 |   ~NTMechanism2DModel() override {}
      |   ^
/home/tav/frc/wpilib/allwpilib/glass/src/libnt/native/include/glass/networktables/NTMechanism2D.h:58:9: note: forward declaration of 'glass::NTMechanism2DModel::RootModel'
   58 |   class RootModel;
      |         ^

```
In file included from /Users/runner/work/allwpilib/allwpilib/glass/src/libnt/native/cpp/NTMechanism2D.cpp:5:
In file included from /Users/runner/work/allwpilib/allwpilib/glass/src/libnt/native/include/glass/networktables/NTMechanism2D.h:7:
In file included from /Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/memory:898:
In file included from /Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/__memory/shared_ptr.h:31:
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/__memory/unique_ptr.h:66:19: error: invalid application of 'sizeof' to an incomplete type '(anonymous namespace)::NTMechanismObjectModel'
    static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type");
                  ^~~~~~~~~~~
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/__memory/unique_ptr.h:300:7: note: in instantiation of member function 'std::default_delete<(anonymous namespace)::NTMechanismObjectModel>::operator()' requested here
      __ptr_.second()(__tmp);
      ^
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/__memory/unique_ptr.h:266:75: note: in instantiation of member function 'std::unique_ptr<(anonymous namespace)::NTMechanismObjectModel>::reset' requested here
  _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); }
                                                                          ^
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/__memory/construct_at.h:69:13: note: in instantiation of member function 'std::unique_ptr<(anonymous namespace)::NTMechanismObjectModel>::~unique_ptr' requested here
    __loc->~_Tp();
            ^
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/__memory/construct_at.h:104:10: note: in instantiation of function template specialization 'std::__destroy_at<std::unique_ptr<(anonymous namespace)::NTMechanismObjectModel>, 0>' requested here
    std::__destroy_at(__loc);
         ^
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/__memory/allocator_traits.h:323:16: note: in instantiation of function template specialization 'std::destroy_at<std::unique_ptr<(anonymous namespace)::NTMechanismObjectModel>, 0>' requested here
        _VSTD::destroy_at(__p);
               ^
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/vector:944:25: note: in instantiation of function template specialization 'std::allocator_traits<std::allocator<std::unique_ptr<(anonymous namespace)::NTMechanismObjectModel>>>::destroy<std::unique_ptr<(anonymous namespace)::NTMechanismObjectModel>, void, void>' requested here
        __alloc_traits::destroy(__alloc(), std::__to_address(--__soon_to_be_end));
                        ^
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/vector:938:29: note: in instantiation of member function 'std::vector<std::unique_ptr<(anonymous namespace)::NTMechanismObjectModel>>::__base_destruct_at_end' requested here
  void __clear() _NOEXCEPT {__base_destruct_at_end(this->__begin_);}
                            ^
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/vector:489:20: note: in instantiation of member function 'std::vector<std::unique_ptr<(anonymous namespace)::NTMechanismObjectModel>>::__clear' requested here
            __vec_.__clear();
                   ^
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/vector:500:67: note: in instantiation of member function 'std::vector<std::unique_ptr<(anonymous namespace)::NTMechanismObjectModel>>::__destroy_vector::operator()' requested here
  _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~vector() { __destroy_vector(*this)(); }
                                                                  ^
/Users/runner/work/allwpilib/allwpilib/glass/src/libnt/native/cpp/NTMechanism2D.cpp:39:3: note: in instantiation of member function 'std::vector<std::unique_ptr<(anonymous namespace)::NTMechanismObjectModel>>::~vector' requested here
  NTMechanismGroupImpl(nt::NetworkTableInstance inst, std::string_view path,
  ^
/Users/runner/work/allwpilib/allwpilib/glass/src/libnt/native/cpp/NTMechanism2D.cpp:35:7: note: forward declaration of '(anonymous namespace)::NTMechanismObjectModel'
class NTMechanismObjectModel;
      ^
```

Explicitly declaring NTMechanismObjectModel's destructor fixes this
specific error, but I get errors for RootModel from other .cpp files
like StandardNetworkTables.cpp as well.
@calcmogul calcmogul requested a review from a team as a code owner June 5, 2025 01:30
@github-actions github-actions bot added the component: glass Glass app and backend label Jun 5, 2025
@PeterJohnson PeterJohnson merged commit 057f5dd into wpilibsuite:main Jun 17, 2025
46 checks passed
@calcmogul calcmogul deleted the glass-fix-compilation-errors-with-cpp23-clang branch June 17, 2025 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: glass Glass app and backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants