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

Compiler errors with libstdc++ in C++20 mode on Ubuntu 23.10 #73037

Open
egorzhdan opened this issue Apr 15, 2024 · 0 comments
Open

Compiler errors with libstdc++ in C++20 mode on Ubuntu 23.10 #73037

egorzhdan opened this issue Apr 15, 2024 · 0 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. c++ interop Feature: Interoperability with C++ compiler The Swift compiler in itself Linux Platform: Linux swift 6.0 test failure

Comments

@egorzhdan
Copy link
Contributor

egorzhdan commented Apr 15, 2024

Description

https://ci.swift.org/job/oss-swift-package-ubuntu-23_10/1/console

/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_construct.h:115:4: error: no matching function for call to 'construct_at'
 92 |   template<typename _Tp, typename... _Args>
 93 |     constexpr auto
 94 |     construct_at(_Tp* __location, _Args&&... __args)
    |     `- note: candidate template ignored: substitution failure [with _Tp = std::chrono::time_zone, _Args = <const std::chrono::time_zone &>]: call to implicitly-deleted copy constructor of 'std::chrono::time_zone'
 95 |     noexcept(noexcept(::new((void*)0) _Tp(std::declval<_Args>()...)))
 96 |     -> decltype(::new((void*)0) _Tp(std::declval<_Args>()...))
    :
113 | 	{
114 | 	  // Allow std::_Construct to be used in constant expressions.
115 | 	  std::construct_at(__p, std::forward<_Args>(__args)...);
    |    `- error: no matching function for call to 'construct_at'
116 | 	  return;
117 | 	}

/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_uninitialized.h:120:11: note: in instantiation of function template specialization 'std::_Construct<std::chrono::time_zone, const std::chrono::time_zone &>' requested here
 118 | 	{
 119 | 	  for (; __first != __last; ++__first, (void)++__cur)
 120 | 	    std::_Construct(std::__addressof(*__cur), *__first);
     |           `- note: in instantiation of function template specialization 'std::_Construct<std::chrono::time_zone, const std::chrono::time_zone &>' requested here
 121 | 	  return __cur;
 122 | 	}
     :
 369 | #ifdef __cpp_lib_is_constant_evaluated
 370 |       if (std::is_constant_evaluated())
 371 | 	return std::__do_uninit_copy(__first, __last, __result);
     |              `- note: in instantiation of function template specialization 'std::__do_uninit_copy<__gnu_cxx::__normal_iterator<const std::chrono::time_zone *, std::vector<std::chrono::time_zone>>, std::chrono::time_zone *>' requested here
 372 | #endif
 373 |       return std::uninitialized_copy(__first, __last, __result);

/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_vector.h:603:9: note: in instantiation of function template specialization 'std::__uninitialized_copy_a<__gnu_cxx::__normal_iterator<const std::chrono::time_zone *, std::vector<std::chrono::time_zone>>, std::chrono::time_zone *, std::chrono::time_zone>' requested here
 601 |       {
 602 | 	this->_M_impl._M_finish =
 603 | 	  std::__uninitialized_copy_a(__x.begin(), __x.end(),
     |         `- note: in instantiation of function template specialization 'std::__uninitialized_copy_a<__gnu_cxx::__normal_iterator<const std::chrono::time_zone *, std::vector<std::chrono::time_zone>>, std::chrono::time_zone *, std::chrono::time_zone>' requested here
 604 | 				      this->_M_impl._M_start,
 605 | 				      _M_get_Tp_allocator());

/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/chrono:2932:12: note: in instantiation of member function 'std::vector<std::chrono::time_zone>::vector' requested here
2930 |       };
2931 | 
2932 |     struct tzdb
     |            `- note: in instantiation of member function 'std::vector<std::chrono::time_zone>::vector' requested here
2933 |     {
2934 |       string version;

/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_construct.h:119:25: error: call to implicitly-deleted copy constructor of 'std::chrono::time_zone'
117 | 	}
118 | #endif
119 |       ::new((void*)__p) _Tp(std::forward<_Args>(__args)...);
    |                         `- error: call to implicitly-deleted copy constructor of 'std::chrono::time_zone'
120 |     }
121 | #else

/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/chrono:2599:7: note: copy constructor is implicitly deleted because 'time_zone' has a user-declared move constructor
2597 |     {
2598 |     public:
2599 |       time_zone(time_zone&&) = default;
     |       `- note: copy constructor is implicitly deleted because 'time_zone' has a user-declared move constructor
2600 |       time_zone& operator=(time_zone&&) = default;
2601 | 

<unknown>:0: note: in implicit copy constructor for 'std::chrono::tzdb' first required here
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_construct.h:115:4: error: no matching function for call to 'construct_at'
 92 |   template<typename _Tp, typename... _Args>
 93 |     constexpr auto
 94 |     construct_at(_Tp* __location, _Args&&... __args)
    |     `- note: candidate template ignored: substitution failure [with _Tp = std::chrono::time_zone_link, _Args = <const std::chrono::time_zone_link &>]: call to implicitly-deleted copy constructor of 'std::chrono::time_zone_link'
 95 |     noexcept(noexcept(::new((void*)0) _Tp(std::declval<_Args>()...)))
 96 |     -> decltype(::new((void*)0) _Tp(std::declval<_Args>()...))
    :
113 | 	{
114 | 	  // Allow std::_Construct to be used in constant expressions.
115 | 	  std::construct_at(__p, std::forward<_Args>(__args)...);
    |    `- error: no matching function for call to 'construct_at'
116 | 	  return;
117 | 	}

/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_uninitialized.h:120:11: note: in instantiation of function template specialization 'std::_Construct<std::chrono::time_zone_link, const std::chrono::time_zone_link &>' requested here
 118 | 	{
 119 | 	  for (; __first != __last; ++__first, (void)++__cur)
 120 | 	    std::_Construct(std::__addressof(*__cur), *__first);
     |           `- note: in instantiation of function template specialization 'std::_Construct<std::chrono::time_zone_link, const std::chrono::time_zone_link &>' requested here
 121 | 	  return __cur;
 122 | 	}
     :
 369 | #ifdef __cpp_lib_is_constant_evaluated
 370 |       if (std::is_constant_evaluated())
 371 | 	return std::__do_uninit_copy(__first, __last, __result);
     |              `- note: in instantiation of function template specialization 'std::__do_uninit_copy<__gnu_cxx::__normal_iterator<const std::chrono::time_zone_link *, std::vector<std::chrono::time_zone_link>>, std::chrono::time_zone_link *>' requested here
 372 | #endif
 373 |       return std::uninitialized_copy(__first, __last, __result);

/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_vector.h:603:9: note: in instantiation of function template specialization 'std::__uninitialized_copy_a<__gnu_cxx::__normal_iterator<const std::chrono::time_zone_link *, std::vector<std::chrono::time_zone_link>>, std::chrono::time_zone_link *, std::chrono::time_zone_link>' requested here
 601 |       {
 602 | 	this->_M_impl._M_finish =
 603 | 	  std::__uninitialized_copy_a(__x.begin(), __x.end(),
     |         `- note: in instantiation of function template specialization 'std::__uninitialized_copy_a<__gnu_cxx::__normal_iterator<const std::chrono::time_zone_link *, std::vector<std::chrono::time_zone_link>>, std::chrono::time_zone_link *, std::chrono::time_zone_link>' requested here
 604 | 				      this->_M_impl._M_start,
 605 | 				      _M_get_Tp_allocator());

/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/chrono:2932:12: note: in instantiation of member function 'std::vector<std::chrono::time_zone_link>::vector' requested here
2930 |       };
2931 | 
2932 |     struct tzdb
     |            `- note: in instantiation of member function 'std::vector<std::chrono::time_zone_link>::vector' requested here
2933 |     {
2934 |       string version;

<unknown>:0: warning: 'import_owned' swift attribute ignored on type 'vector': type is not copyable or destructible
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_construct.h:119:25: error: call to implicitly-deleted copy constructor of 'std::chrono::time_zone_link'
117 | 	}
118 | #endif
119 |       ::new((void*)__p) _Tp(std::forward<_Args>(__args)...);
    |                         `- error: call to implicitly-deleted copy constructor of 'std::chrono::time_zone_link'
120 |     }
121 | #else

/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/chrono:2787:7: note: copy constructor is implicitly deleted because 'time_zone_link' has a user-declared move constructor
2785 |     {
2786 |     public:
2787 |       time_zone_link(time_zone_link&&) = default;
     |       `- note: copy constructor is implicitly deleted because 'time_zone_link' has a user-declared move constructor
2788 |       time_zone_link& operator=(time_zone_link&&) = default;
2789 | 

Reproduction

Run the use-std-string.swift test

Expected behavior

The test passes

Environment

Ubuntu 23.10
libstdc++ 13

Additional information

No response

@egorzhdan egorzhdan added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. c++ interop Feature: Interoperability with C++ compiler The Swift compiler in itself labels Apr 15, 2024
@egorzhdan egorzhdan self-assigned this Apr 15, 2024
@egorzhdan egorzhdan changed the title Compiler errors with libstdc++ in C++20 mode on Ubuntu 23.04 Compiler errors with libstdc++ in C++20 mode on Ubuntu 23.10 Apr 15, 2024
egorzhdan added a commit that referenced this issue Apr 17, 2024
In libstdc++13 on Ubuntu 23.10 the type `std::tzdb` is non-copyable but does not explicitly delete its copy constructor. It instead triggers template instantiation errors when trying to use the copy constructor. This is problematic for Swift, since we try to instantiate copy constructors for most C++ types we import.

This disables the import of `std::tzdb` to unblock nightly toolchains for Ubuntu 23.10 until we come up with a better solution.

rdar://126486849 / #73037
egorzhdan added a commit that referenced this issue Apr 18, 2024
`tzdb` is declared inside of `namespace chrono`, so the check needs to be adjusted.

rdar://126486849 / #73037
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. c++ interop Feature: Interoperability with C++ compiler The Swift compiler in itself Linux Platform: Linux swift 6.0 test failure
Projects
None yet
Development

No branches or pull requests

2 participants