Post

Replies

Boosts

Views

Activity

Reply to [Bug] std::variant in containers triggers UBSan error in Xcode 16.x
Thanks for looking into this. I've done more testing and found that the issue is broader than originally shown. The problem occurs with complex types in the variant, regardless of monostate. This minimal case triggers the error: class Item { public: std::variant<std::string> value; }; typedef std::forward_list<Item> ItemList; class Test { public: void addItem(const Item& item); ItemList items; }; While the remaining code and compilation steps are the same.
1d
Reply to [Bug] std::variant in containers triggers UBSan error in Xcode 16.x
@endecotp : /Applications/Xcode-16.0/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/c++/v1/variant:495:12: runtime error: call to function decltype(auto) std::__1::__variant_detail::__visitation::__base::__dispatcher<0ul, 0ul>::__dispatch[abi:de180100]<void std::__1::__variant_detail::__ctor<std::__1::__variant_detail::__traits<std::__1::monostate, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>::__generic_construct[abi:de180100]<std::__1::__variant_detail::__copy_constructor<std::__1::__variant_detail::__traits<std::__1::monostate, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, (std::__1::__variant_detail::_Trait)1> const&>(std::__1::__variant_detail::__ctor<std::__1::__variant_detail::__traits<std::__1::monostate, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>&, std::__1::__variant_detail::__copy_constructor<std::__1::__variant_detail::__traits<std::__1::monostate, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, (std::__1::__variant_detail::_Trait)1> const&)::'lambda'(std::__1::__variant_detail::__copy_constructor<std::__1::__variant_detail::__traits<std::__1::monostate, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, (std::__1::__variant_detail::_Trait)1> const&, auto&&)&&, std::__1::__variant_detail::__base<(std::__1::__variant_detail::_Trait)1, std::__1::monostate, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>&, std::__1::__variant_detail::__base<(std::__1::__variant_detail::_Trait)1, std::__1::monostate, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>> const&>(std::__1::__variant_detail::__copy_constructor<std::__1::__variant_detail::__traits<std::__1::monostate, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, (std::__1::__variant_detail::_Trait)1> const&, std::__1::__variant_detail::__base<(std::__1::__variant_detail::_Trait)1, std::__1::monostate, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>&, std::__1::__variant_detail::__base<(std::__1::__variant_detail::_Trait)1, std::__1::monostate, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>> const&) through pointer to incorrect function type 'void (*)((lambda at /Applications/Xcode-16.0/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/c++/v1/variant:814:11) &&, std::__variant_detail::__base<std::__variant_detail::_Trait::_Available, std::monostate, std::string> &, const std::__variant_detail::__base<std::__variant_detail::_Trait::_Available, std::monostate, std::string> &)' variant:532: note: decltype(auto) std::__1::__variant_detail::__visitation::__base::__dispatcher<0ul, 0ul>::__dispatch[abi:de180100]<void std::__1::__variant_detail::__ctor<std::__1::__variant_detail::__traits<std::__1::monostate, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>::__generic_construct[abi:de180100]<std::__1::__variant_detail::__copy_constructor<std::__1::__variant_detail::__traits<std::__1::monostate, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, (std::__1::__variant_detail::_Trait)1> const&>(std::__1::__variant_detail::__ctor<std::__1::__variant_detail::__traits<std::__1::monostate, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>&, std::__1::__variant_detail::__copy_constructor<std::__1::__variant_detail::__traits<std::__1::monostate, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, (std::__1::__variant_detail::_Trait)1> const&)::'lambda'(std::__1::__variant_detail::__copy_constructor<std::__1::__variant_detail::__traits<std::__1::monostate, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, (std::__1::__variant_detail::_Trait)1> const&, auto&&)&&, std::__1::__variant_detail::__base<(std::__1::__variant_detail::_Trait)1, std::__1::monostate, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>&, std::__1::__variant_detail::__base<(std::__1::__variant_detail::_Trait)1, std::__1::monostate, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>> const&>(std::__1::__variant_detail::__copy_constructor<std::__1::__variant_detail::__traits<std::__1::monostate, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, (std::__1::__variant_detail::_Trait)1> const&, std::__1::__variant_detail::__base<(std::__1::__variant_detail::_Trait)1, std::__1::monostate, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>&, std::__1::__variant_detail::__base<(std::__1::__variant_detail::_Trait)1, std::__1::monostate, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>> const&) defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Applications/Xcode-16.0/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/c++/v1/variant:495:12 This error appears only on Xcode 16*
2w