Bug#877838: clang-5.0: c++17 std::get(std::variant) fails to compile with libstdc++
Daniele Di Proietto
daniele.di.proietto at gmail.com
Fri Oct 6 02:21:31 UTC 2017
Package: clang-5.0
Version: 1:5.0~+rc2-1
Severity: normal
Dear Maintainer,
I'm trying to compile c++17 code that uses `std::get(std::variant)`.
It appears to work with g++-7, but it fails with clang++-5.0.
$ cat variant.cc
#include <variant>
int main() {
std::variant<int, float> v{42};
int i = std::get<int>(v);
}
$ g++-7 -std=c++1z variant.cc -o variant
$ clang++-5.0 -std=c++1z variant.cc -o variant
In file included from variant.cc:1:
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.1.0/../../../../include/c++/7.1.0/variant:235:46: error: cannot cast 'std::variant<int, float>' to its
private base class 'std::__detail::__variant::_Variant_storage<true, int, float>'
return __get(std::in_place_index<_Np>, std::forward<_Variant>(__v)._M_u);
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.1.0/../../../../include/c++/7.1.0/variant:1192:35: note: in instantiation of function template specialization
'std::__detail::__variant::__get<0, std::variant<int, float> &>' requested here
return __detail::__variant::__get<_Np>(__v);
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.1.0/../../../../include/c++/7.1.0/variant:739:14: note: in instantiation of function template specialization
'std::get<0, int, float>' requested here
return get<__detail::__variant::__index_of_v<_Tp, _Types...>>(__v);
^
variant.cc:5:16: note: in instantiation of function template specialization 'std::get<int, int, float>' requested here
int i = std::get<int>(v);
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.1.0/../../../../include/c++/7.1.0/variant:878:7: note: constrained by private inheritance here
: private __detail::__variant::_Variant_base<_Types...>,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.1.0/../../../../include/c++/7.1.0/variant:235:74: error: '_M_u' is a private member of
'std::__detail::__variant::_Variant_storage<true, int, float>'
return __get(std::in_place_index<_Np>, std::forward<_Variant>(__v)._M_u);
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.1.0/../../../../include/c++/7.1.0/variant:878:7: note: constrained by private inheritance here
: private __detail::__variant::_Variant_base<_Types...>,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.1.0/../../../../include/c++/7.1.0/variant:377:34: note: member is declared here
_Variadic_union<_Types...> _M_u;
^
2 errors generated.
Unrelated: I've tried with libc++ 4.0.1-1 from unstable, but I see a failure similar to #855222
Please let me know if additional information is needed.
Thanks,
Daniele
-- System Information:
Debian Release: 9.1
APT prefers stable
APT policy: (900, 'stable'), (500, 'unstable-debug'), (500, 'testing-debug'), (500, 'stable-debug')
Architecture: amd64 (x86_64)
Kernel: Linux 4.9.0-3-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages clang-5.0 depends on:
ii binutils 2.28-5
ii libc6 2.24-14
ii libc6-dev 2.24-14
ii libclang-common-5.0-dev 1:5.0~+rc2-1
ii libclang1-5.0 1:5.0~+rc2-1
ii libgcc-6-dev 6.3.0-18
ii libgcc1 1:7.1.0-7
ii libjsoncpp1 1.7.4-3
ii libllvm5.0 1:5.0~+rc2-1
ii libobjc-6-dev 6.3.0-18
ii libstdc++-6-dev 6.3.0-18
ii libstdc++6 7.1.0-7
ii libtinfo5 6.0+20161126-1
ii zlib1g 1:1.2.8.dfsg-5
Versions of packages clang-5.0 recommends:
pn llvm-5.0-dev <none>
ii python 2.7.13-2
Versions of packages clang-5.0 suggests:
pn clang-5.0-doc <none>
pn gnustep <none>
pn gnustep-devel <none>
pn libomp-dev <none>
-- debconf-show failed
More information about the Pkg-llvm-team
mailing list