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

[21981] 'may be used uninitialized' compile error in TypeObjectRegistry #5277

Open
1 task done
owillebo opened this issue Sep 27, 2024 · 4 comments
Open
1 task done
Labels
in progress Issue or PR which is being reviewed

Comments

@owillebo
Copy link

Is there an already existing issue for this?

  • I have searched the existing issues

Expected behavior

Build succeeds.

Current behavior

Build fails, with the following output;

Starting >>> fastcdr
Starting >>> foonathan_memory_vendor
Finished <<< fastcdr [3.46s]
--- stderr: foonathan_memory_vendor
Cloning into 'foo_mem-ext'...
HEAD is now at 0f07757 Release 0.7-3
---
Finished <<< foonathan_memory_vendor [16.3s]
Starting >>> fastdds
--- stderr: fastdds
In file included from /usr/include/c++/12/string:53,
                 from /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/include/fastdds/dds/xtypes/type_representation/TypeObjectUtils.hpp:23,
                 from /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/src/cpp/fastdds/xtypes/type_representation/TypeObjectUtils.cpp:15:
In member function ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::pointer std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_data() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’,
    inlined from ‘bool std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_is_local() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:274:23,
    inlined from ‘void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_dispose() [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:285:18,
    inlined from ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::~basic_string() [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:795:19,
    inlined from ‘eprosima::fastdds::dds::xtypes::AppliedVerbatimAnnotation::~AppliedVerbatimAnnotation()’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobject.hpp:6528:5,
    inlined from ‘eprosima::fastcdr::detail::optional_storage<T, <template-parameter-1-2> >::~optional_storage() [with T = eprosima::fastdds::dds::xtypes::AppliedVerbatimAnnotation; <template-parameter-1-2> = void]’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/install/fastcdr/include/fastcdr/xcdr/detail/optional.hpp:42:20,
    inlined from ‘eprosima::fastcdr::optional<T>::~optional() [with T = eprosima::fastdds::dds::xtypes::AppliedVerbatimAnnotation]’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/install/fastcdr/include/fastcdr/xcdr/optional.hpp:88:5,
    inlined from ‘eprosima::fastdds::dds::xtypes::AppliedBuiltinTypeAnnotations::AppliedBuiltinTypeAnnotations(const eprosima::fastdds::dds::xtypes::AppliedBuiltinTypeAnnotations&)’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobject.hpp:7981:5,
    inlined from ‘eprosima::fastcdr::optional<T>& eprosima::fastcdr::optional<T>::operator=(const eprosima::fastcdr::optional<T>&) [with T = eprosima::fastdds::dds::xtypes::AppliedBuiltinTypeAnnotations]’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/install/fastcdr/include/fastcdr/xcdr/optional.hpp:209:13,
    inlined from ‘eprosima::fastdds::dds::xtypes::CompleteTypeDetail::CompleteTypeDetail(const eprosima::fastdds::dds::xtypes::CompleteTypeDetail&)’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobject.hpp:8207:39,
    inlined from ‘eprosima::fastcdr::optional<T>& eprosima::fastcdr::optional<T>::operator=(const eprosima::fastcdr::optional<T>&) [with T = eprosima::fastdds::dds::xtypes::CompleteTypeDetail]’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/install/fastcdr/include/fastcdr/xcdr/optional.hpp:209:13,
    inlined from ‘eprosima::fastdds::dds::xtypes::CompleteCollectionHeader& eprosima::fastdds::dds::xtypes::CompleteCollectionHeader::operator=(const eprosima::fastdds::dds::xtypes::CompleteCollectionHeader&)’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobject.hpp:14597:34,
    inlined from ‘eprosima::fastdds::dds::xtypes::CompleteMapType& eprosima::fastdds::dds::xtypes::CompleteMapType::operator=(const eprosima::fastdds::dds::xtypes::CompleteMapType&)’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobject.hpp:16270:34,
    inlined from ‘void eprosima::fastdds::dds::xtypes::CompleteTypeObject::map_type(const eprosima::fastdds::dds::xtypes::CompleteMapType&)’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobject.hpp:21508:23,
    inlined from ‘static eprosima::fastdds::dds::xtypes::ReturnCode_t eprosima::fastdds::dds::xtypes::TypeObjectUtils::build_and_register_map_type_object(const eprosima::fastdds::dds::xtypes::CompleteMapType&, const std::string&)’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/src/cpp/fastdds/xtypes/type_representation/TypeObjectUtils.cpp:1776:25:
/usr/include/c++/12/bits/basic_string.h:234:28: error: ‘((const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)((char*)&type_object + offsetof(eprosima::fastdds::dds::xtypes::CompleteTypeObject, eprosima::fastdds::dds::xtypes::CompleteTypeObject::<unnamed>) + 16))[3].std::__cxx11::basic_string<char>::_M_dataplus.std::__cxx11::basic_string<char>::_Alloc_hider::_M_p’ may be used uninitialized [-Werror=maybe-uninitialized]
  234 |       { return _M_dataplus._M_p; }
      |                            ^~~~
/home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/src/cpp/fastdds/xtypes/type_representation/TypeObjectUtils.cpp: In static member function ‘static eprosima::fastdds::dds::xtypes::ReturnCode_t eprosima::fastdds::dds::xtypes::TypeObjectUtils::build_and_register_map_type_object(const eprosima::fastdds::dds::xtypes::CompleteMapType&, const std::string&)’:
/home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/src/cpp/fastdds/xtypes/type_representation/TypeObjectUtils.cpp:1775:24: note: ‘type_object’ declared here
 1775 |     CompleteTypeObject type_object;
      |                        ^~~~~~~~~~~
In member function ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::pointer std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_data() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’,
    inlined from ‘bool std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_is_local() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:274:23,
    inlined from ‘void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_dispose() [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:285:18,
    inlined from ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::~basic_string() [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:795:19,
    inlined from ‘eprosima::fastdds::dds::xtypes::AppliedVerbatimAnnotation::~AppliedVerbatimAnnotation()’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobject.hpp:6528:5,
    inlined from ‘eprosima::fastcdr::detail::optional_storage<T, <template-parameter-1-2> >::~optional_storage() [with T = eprosima::fastdds::dds::xtypes::AppliedVerbatimAnnotation; <template-parameter-1-2> = void]’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/install/fastcdr/include/fastcdr/xcdr/detail/optional.hpp:42:20,
    inlined from ‘eprosima::fastcdr::optional<T>::~optional() [with T = eprosima::fastdds::dds::xtypes::AppliedVerbatimAnnotation]’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/install/fastcdr/include/fastcdr/xcdr/optional.hpp:88:5,
    inlined from ‘eprosima::fastdds::dds::xtypes::AppliedBuiltinTypeAnnotations::AppliedBuiltinTypeAnnotations(const eprosima::fastdds::dds::xtypes::AppliedBuiltinTypeAnnotations&)’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobject.hpp:7981:5,
    inlined from ‘eprosima::fastcdr::optional<T>& eprosima::fastcdr::optional<T>::operator=(const eprosima::fastcdr::optional<T>&) [with T = eprosima::fastdds::dds::xtypes::AppliedBuiltinTypeAnnotations]’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/install/fastcdr/include/fastcdr/xcdr/optional.hpp:209:13,
    inlined from ‘eprosima::fastdds::dds::xtypes::CompleteTypeDetail::CompleteTypeDetail(const eprosima::fastdds::dds::xtypes::CompleteTypeDetail&)’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobject.hpp:8207:39,
    inlined from ‘eprosima::fastcdr::optional<T>& eprosima::fastcdr::optional<T>::operator=(const eprosima::fastcdr::optional<T>&) [with T = eprosima::fastdds::dds::xtypes::CompleteTypeDetail]’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/install/fastcdr/include/fastcdr/xcdr/optional.hpp:209:13,
    inlined from ‘eprosima::fastdds::dds::xtypes::CompleteCollectionHeader& eprosima::fastdds::dds::xtypes::CompleteCollectionHeader::operator=(const eprosima::fastdds::dds::xtypes::CompleteCollectionHeader&)’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobject.hpp:14597:34,
    inlined from ‘eprosima::fastdds::dds::xtypes::CompleteSequenceType& eprosima::fastdds::dds::xtypes::CompleteSequenceType::operator=(const eprosima::fastdds::dds::xtypes::CompleteSequenceType&)’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobject.hpp:14913:34,
    inlined from ‘void eprosima::fastdds::dds::xtypes::CompleteTypeObject::sequence_type(const eprosima::fastdds::dds::xtypes::CompleteSequenceType&)’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobject.hpp:21402:28,
    inlined from ‘static eprosima::fastdds::dds::xtypes::ReturnCode_t eprosima::fastdds::dds::xtypes::TypeObjectUtils::build_and_register_sequence_type_object(const eprosima::fastdds::dds::xtypes::CompleteSequenceType&, const std::string&)’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/src/cpp/fastdds/xtypes/type_representation/TypeObjectUtils.cpp:1750:30:
/usr/include/c++/12/bits/basic_string.h:234:28: error: ‘((const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)((char*)&type_object + offsetof(eprosima::fastdds::dds::xtypes::CompleteTypeObject, eprosima::fastdds::dds::xtypes::CompleteTypeObject::<unnamed>) + 16))[3].std::__cxx11::basic_string<char>::_M_dataplus.std::__cxx11::basic_string<char>::_Alloc_hider::_M_p’ may be used uninitialized [-Werror=maybe-uninitialized]
  234 |       { return _M_dataplus._M_p; }
      |                            ^~~~
/home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/src/cpp/fastdds/xtypes/type_representation/TypeObjectUtils.cpp: In static member function ‘static eprosima::fastdds::dds::xtypes::ReturnCode_t eprosima::fastdds::dds::xtypes::TypeObjectUtils::build_and_register_sequence_type_object(const eprosima::fastdds::dds::xtypes::CompleteSequenceType&, const std::string&)’:
/home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/src/cpp/fastdds/xtypes/type_representation/TypeObjectUtils.cpp:1749:24: note: ‘type_object’ declared here
 1749 |     CompleteTypeObject type_object;
      |                        ^~~~~~~~~~~
In member function ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::pointer std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_data() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’,
    inlined from ‘bool std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_is_local() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:274:23,
    inlined from ‘void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_dispose() [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:285:18,
    inlined from ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::~basic_string() [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:795:19,
    inlined from ‘eprosima::fastdds::dds::xtypes::AppliedVerbatimAnnotation::~AppliedVerbatimAnnotation()’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobject.hpp:6528:5,
    inlined from ‘eprosima::fastcdr::detail::optional_storage<T, <template-parameter-1-2> >::~optional_storage() [with T = eprosima::fastdds::dds::xtypes::AppliedVerbatimAnnotation; <template-parameter-1-2> = void]’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/install/fastcdr/include/fastcdr/xcdr/detail/optional.hpp:42:20,
    inlined from ‘eprosima::fastcdr::optional<T>::~optional() [with T = eprosima::fastdds::dds::xtypes::AppliedVerbatimAnnotation]’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/install/fastcdr/include/fastcdr/xcdr/optional.hpp:88:5,
    inlined from ‘eprosima::fastdds::dds::xtypes::AppliedBuiltinTypeAnnotations::AppliedBuiltinTypeAnnotations(const eprosima::fastdds::dds::xtypes::AppliedBuiltinTypeAnnotations&)’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobject.hpp:7981:5,
    inlined from ‘eprosima::fastcdr::optional<T>& eprosima::fastcdr::optional<T>::operator=(const eprosima::fastcdr::optional<T>&) [with T = eprosima::fastdds::dds::xtypes::AppliedBuiltinTypeAnnotations]’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/install/fastcdr/include/fastcdr/xcdr/optional.hpp:209:13,
    inlined from ‘eprosima::fastdds::dds::xtypes::CompleteDiscriminatorMember& eprosima::fastdds::dds::xtypes::CompleteDiscriminatorMember::operator=(const eprosima::fastdds::dds::xtypes::CompleteDiscriminatorMember&)’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobject.hpp:10088:39,
    inlined from ‘eprosima::fastdds::dds::xtypes::CompleteUnionType& eprosima::fastdds::dds::xtypes::CompleteUnionType::operator=(const eprosima::fastdds::dds::xtypes::CompleteUnionType&)’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobject.hpp:10719:41,
    inlined from ‘void eprosima::fastdds::dds::xtypes::CompleteTypeObject::union_type(const eprosima::fastdds::dds::xtypes::CompleteUnionType&)’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobject.hpp:21296:25,
    inlined from ‘static eprosima::fastdds::dds::xtypes::ReturnCode_t eprosima::fastdds::dds::xtypes::TypeObjectUtils::build_and_register_union_type_object(const eprosima::fastdds::dds::xtypes::CompleteUnionType&, const std::string&, eprosima::fastdds::dds::xtypes::TypeIdentifierPair&)’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/src/cpp/fastdds/xtypes/type_representation/TypeObjectUtils.cpp:1725:27:
/usr/include/c++/12/bits/basic_string.h:234:28: error: ‘((const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)((char*)&type_object + offsetof(eprosima::fastdds::dds::xtypes::CompleteTypeObject, eprosima::fastdds::dds::xtypes::CompleteTypeObject::<unnamed>)))[21].std::__cxx11::basic_string<char>::_M_dataplus.std::__cxx11::basic_string<char>::_Alloc_hider::_M_p’ may be used uninitialized [-Werror=maybe-uninitialized]
  234 |       { return _M_dataplus._M_p; }
      |                            ^~~~
/home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/src/cpp/fastdds/xtypes/type_representation/TypeObjectUtils.cpp: In static member function ‘static eprosima::fastdds::dds::xtypes::ReturnCode_t eprosima::fastdds::dds::xtypes::TypeObjectUtils::build_and_register_union_type_object(const eprosima::fastdds::dds::xtypes::CompleteUnionType&, const std::string&, eprosima::fastdds::dds::xtypes::TypeIdentifierPair&)’:
/home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/src/cpp/fastdds/xtypes/type_representation/TypeObjectUtils.cpp:1724:24: note: ‘type_object’ declared here
 1724 |     CompleteTypeObject type_object;
      |                        ^~~~~~~~~~~
cc1plus: all warnings being treated as errors
gmake[2]: *** [src/cpp/CMakeFiles/fastdds.dir/build.make:1168: src/cpp/CMakeFiles/fastdds.dir/fastdds/xtypes/type_representation/TypeObjectUtils.cpp.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
In file included from /usr/include/c++/12/string:53,
                 from /usr/include/c++/12/stdexcept:39,
                 from /usr/include/c++/12/system_error:41,
                 from /usr/include/c++/12/mutex:41,
                 from /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.hpp:23,
                 from /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp:15:
In member function ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::pointer std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_data() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’,
    inlined from ‘bool std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_is_local() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:274:23,
    inlined from ‘void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_dispose() [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:285:18,
    inlined from ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::~basic_string() [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12/bits/basic_string.h:795:19,
    inlined from ‘eprosima::fastdds::dds::xtypes::AppliedVerbatimAnnotation::~AppliedVerbatimAnnotation()’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobject.hpp:6528:5,
    inlined from ‘eprosima::fastcdr::detail::optional_storage<T, <template-parameter-1-2> >::~optional_storage() [with T = eprosima::fastdds::dds::xtypes::AppliedVerbatimAnnotation; <template-parameter-1-2> = void]’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/install/fastcdr/include/fastcdr/xcdr/detail/optional.hpp:42:20,
    inlined from ‘eprosima::fastcdr::optional<T>::~optional() [with T = eprosima::fastdds::dds::xtypes::AppliedVerbatimAnnotation]’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/install/fastcdr/include/fastcdr/xcdr/optional.hpp:88:5,
    inlined from ‘eprosima::fastdds::dds::xtypes::AppliedBuiltinTypeAnnotations::AppliedBuiltinTypeAnnotations(const eprosima::fastdds::dds::xtypes::AppliedBuiltinTypeAnnotations&)’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobject.hpp:7981:5,
    inlined from ‘eprosima::fastcdr::optional<T>& eprosima::fastcdr::optional<T>::operator=(const eprosima::fastcdr::optional<T>&) [with T = eprosima::fastdds::dds::xtypes::AppliedBuiltinTypeAnnotations]’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/install/fastcdr/include/fastcdr/xcdr/optional.hpp:209:13,
    inlined from ‘eprosima::fastdds::dds::xtypes::CompleteDiscriminatorMember& eprosima::fastdds::dds::xtypes::CompleteDiscriminatorMember::operator=(const eprosima::fastdds::dds::xtypes::CompleteDiscriminatorMember&)’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobject.hpp:10088:39,
    inlined from ‘eprosima::fastdds::dds::xtypes::CompleteUnionType& eprosima::fastdds::dds::xtypes::CompleteUnionType::operator=(const eprosima::fastdds::dds::xtypes::CompleteUnionType&)’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobject.hpp:10719:41,
    inlined from ‘void eprosima::fastdds::dds::xtypes::CompleteTypeObject::union_type(const eprosima::fastdds::dds::xtypes::CompleteUnionType&)’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobject.hpp:21296:25,
    inlined from ‘eprosima::fastdds::dds::xtypes::ReturnCode_t eprosima::fastdds::dds::xtypes::TypeObjectRegistry::register_typeobject_w_union_dynamic_type(const eprosima::fastdds::dds::traits<eprosima::fastdds::dds::DynamicTypeImpl>::ref_type&, eprosima::fastdds::dds::xtypes::TypeIdentifierPair&)’ at /home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp:1859:35:
/usr/include/c++/12/bits/basic_string.h:234:28: error: ‘((const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)((char*)&complete_typeobject + offsetof(eprosima::fastdds::dds::xtypes::CompleteTypeObject, eprosima::fastdds::dds::xtypes::CompleteTypeObject::<unnamed>)))[21].std::__cxx11::basic_string<char>::_M_dataplus.std::__cxx11::basic_string<char>::_Alloc_hider::_M_p’ may be used uninitialized [-Werror=maybe-uninitialized]
  234 |       { return _M_dataplus._M_p; }
      |                            ^~~~
/home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp: In member function ‘eprosima::fastdds::dds::xtypes::ReturnCode_t eprosima::fastdds::dds::xtypes::TypeObjectRegistry::register_typeobject_w_union_dynamic_type(const eprosima::fastdds::dds::traits<eprosima::fastdds::dds::DynamicTypeImpl>::ref_type&, eprosima::fastdds::dds::xtypes::TypeIdentifierPair&)’:
/home/willeboordseo/rtps/eProsima/Fast-DDS/src/fastdds/src/cpp/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp:1858:24: note: ‘complete_typeobject’ declared here
 1858 |     CompleteTypeObject complete_typeobject;
      |                        ^~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
gmake[2]: *** [src/cpp/CMakeFiles/fastdds.dir/build.make:1154: src/cpp/CMakeFiles/fastdds.dir/fastdds/xtypes/type_representation/TypeObjectRegistry.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:976: src/cpp/CMakeFiles/fastdds.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2
---
Failed   <<< fastdds [1min 2s, exited with code 2]
[Processing: fastdds]
[Processing: fastdds]

Summary: 2 packages finished [1min 19s]
  1 package failed: fastdds
  2 packages had stderr output: fastdds foonathan_memory_vendor

Steps to reproduce

colcon build --packages-up-to fastdds

Fast DDS version/commit

repositories:
    foonathan_memory_vendor:
        type: git
        url: https://github.com/eProsima/foonathan_memory_vendor.git
        version: v1.3.1
    fastcdr:
        type: git
        url: https://github.com/eProsima/Fast-CDR.git
        version: v2.2.4
    fastdds:
        type: git
        url: https://github.com/eProsima/Fast-DDS.git
        version: v3.0.1
    fastddsgen:
        type: git
        url: https://github.com/eProsima/Fast-DDS-Gen.git
        version: v4.0.1

Platform/Architecture

Other. Please specify in Additional context section.

Transport layer

Default configuration, UDPv4 & SHM

Additional context

gcc (Debian 12.2.0-14) 12.2.0

cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

XML configuration file

NA

Relevant log output

NA

Network traffic capture

NA

@owillebo owillebo added the triage Issue pending classification label Sep 27, 2024
@owillebo
Copy link
Author

owillebo commented Sep 27, 2024

If I add src/fastdds/CMakeLists.txt as follows then the build succeeds.

image

@aldas
Copy link

aldas commented Oct 23, 2024

can confirm same problem. This can be replicated with this Dockerfile

FROM python:3.12-slim-bookworm

# Fast-DDS library related versions
ARG version_foonathan_memory_vendor=v1.3.1
ARG version_fastcdr=v2.2.5
ARG version_fastdds=v3.1.0

ENV version_foonathan_memory_vendor=${version_foonathan_memory_vendor}
ENV version_fastcdr=${version_fastcdr}
ENV version_fastdds=${version_fastdds}

ENV INSTALL_PREFIX=/usr/local

RUN apt update &&  \
    apt install -y --no-install-recommends \
        git \
        build-essential \
        cmake \
        wget \
        libssl-dev \
        libasio-dev \
        libtinyxml2-dev \
        libpython3-dev \
        libwebsocketpp-dev

# Install `colcon` and `vcs`
RUN pip install -U colcon-common-extensions vcstool

WORKDIR /fastdds_ws
RUN mkdir -p /fastdds_ws/src && \
    git clone --depth 1 --branch ${version_foonathan_memory_vendor} https://github.com/eProsima/foonathan_memory_vendor.git /fastdds_ws/src/foonathan_memory_vendor && \
    git clone --depth 1 --branch ${version_fastcdr} https://github.com/eProsima/Fast-CDR.git /fastdds_ws/src/fastcdr && \
    git clone --depth 1 --branch ${version_fastdds} https://github.com/eProsima/Fast-DDS.git /fastdds_ws/src/fastdds

RUN mkdir -p /fastdds_ws/build/foonathan_memory_vendor && \
    cd /fastdds_ws/build/foonathan_memory_vendor && \
    cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
            /fastdds_ws/src/foonathan_memory_vendor && \
    cmake --build . --target install

RUN mkdir -p /fastdds_ws/build/fastcdr && \
    cd /fastdds_ws/build/fastcdr && \
    cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
          -DBUILD_SHARED_LIBS=TRUE \
            /fastdds_ws/src/fastcdr && \
    cmake --build . --target install

RUN mkdir -p /fastdds_ws/build/fastdds && \
    cd /fastdds_ws/build/fastdds && \
    cmake -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} \
        -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
        -DBUILD_SHARED_LIBS=TRUE \
        -DSECURITY=ON \
        -DCOMPILE_EXAMPLES=OFF \
        -DINSTALL_EXAMPLES=OFF \
        /fastdds_ws/src/fastdds && \
    cmake --build . --target install

output:

696.4     inlined from ‘void eprosima::fastdds::dds::xtypes::CompleteTypeObject::union_type(const eprosima::fastdds::dds::xtypes::CompleteUnionType&)’ at /fastdds_ws/src/fastdds/include/fastdds/dds/xtypes/type_representation/detail/dds_xtypes_typeobject.hpp:21332:25,
696.4     inlined from ‘static eprosima::fastdds::dds::xtypes::ReturnCode_t eprosima::fastdds::dds::xtypes::TypeObjectUtils::build_and_register_union_type_object(const eprosima::fastdds::dds::xtypes::CompleteUnionType&, const std::string&, eprosima::fastdds::dds::xtypes::TypeIdentifierPair&)’ at /fastdds_ws/src/fastdds/src/cpp/fastdds/xtypes/type_representation/TypeObjectUtils.cpp:1725:27:
696.4 /usr/include/c++/12/bits/basic_string.h:234:28: error: ‘((const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)((char*)&type_object + offsetof(eprosima::fastdds::dds::xtypes::CompleteTypeObject, eprosima::fastdds::dds::xtypes::CompleteTypeObject::<unnamed>)))[21].std::__cxx11::basic_string<char>::_M_dataplus.std::__cxx11::basic_string<char>::_Alloc_hider::_M_p’ may be used uninitialized [-Werror=maybe-uninitialized]
696.4   234 |       { return _M_dataplus._M_p; }
696.4       |                            ^~~~
696.4 /fastdds_ws/src/fastdds/src/cpp/fastdds/xtypes/type_representation/TypeObjectUtils.cpp: In static member function ‘static eprosima::fastdds::dds::xtypes::ReturnCode_t eprosima::fastdds::dds::xtypes::TypeObjectUtils::build_and_register_union_type_object(const eprosima::fastdds::dds::xtypes::CompleteUnionType&, const std::string&, eprosima::fastdds::dds::xtypes::TypeIdentifierPair&)’:
696.4 /fastdds_ws/src/fastdds/src/cpp/fastdds/xtypes/type_representation/TypeObjectUtils.cpp:1724:24: note: ‘type_object’ declared here
696.4  1724 |     CompleteTypeObject type_object;
696.4       |                        ^~~~~~~~~~~
697.2 cc1plus: all warnings being treated as errors
697.3 gmake[2]: *** [src/cpp/CMakeFiles/fastdds.dir/build.make:1168: src/cpp/CMakeFiles/fastdds.dir/fastdds/xtypes/type_representation/TypeObjectUtils.cpp.o] Error 1
697.3 gmake[1]: *** [CMakeFiles/Makefile2:976: src/cpp/CMakeFiles/fastdds.dir/all] Error 2
697.3 gmake: *** [Makefile:146: all] Error 2

@JesusPoderoso
Copy link
Contributor

Hi @owillebo, @aldas, thanks for your report.
We are working towards fixing this issue.
In the meantime, apply @owillebo's solution with the CMake flag -Wno-maybe-uninitialized.
Thanks!

@JesusPoderoso JesusPoderoso changed the title 'may be used uninitialized' compile error in TypeObjectRegistry [21981] 'may be used uninitialized' compile error in TypeObjectRegistry Oct 24, 2024
@JesusPoderoso JesusPoderoso added in progress Issue or PR which is being reviewed and removed triage Issue pending classification labels Oct 24, 2024
@tdy-mkristiansen
Copy link

Attached is a patch that disables the warning locally.

More info:
Problem is caused by class optional_storage. GCC can't figure out if the memory is initialized or not and therefore warns. Doesn't seem like a real issue.
issue-5277.diff.gz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in progress Issue or PR which is being reviewed
Projects
None yet
Development

No branches or pull requests

4 participants