[Bug libstdc++/80737] variant as class member resulting to compile errors

2017-05-13 Thread timshen at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80737

--- Comment #3 from Tim Shen  ---
(In reply to TC from comment #1)
> Looks like the constraint on the convert-everything constructor needs to
> check for is_same, variant> first and short circuit if that's
> true.

I'm not quite sure whether we need that short circuit - it's in a SFINAE
environment, so if anything goes wrong, there shouldn't be a hard error.
Therefore even if I agree that we should check is_same, variant>
first, that shouldn't affect the correctness.

[Bug libstdc++/80737] variant as class member resulting to compile errors

2017-05-13 Thread timshen at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80737

Tim Shen  changed:

   What|Removed |Added

 CC||timshen at gcc dot gnu.org

--- Comment #2 from Tim Shen  ---
I reduced the test case a bit, noticing that a seemingly trivial change to
 makes it compile. Here it is: https://godbolt.org/g/tQowts

Defining the macro BUG reproduces the compile failure, however the code in BUG
should have the same meaning as the other branch - it merely uses a type alias.

FWIW clang 5.0.0 compiles the pre-processed code with/without -DBUG.

I believe that it's a GCC frontend issue.

[Bug libstdc++/80737] variant as class member resulting to compile errors

2017-05-13 Thread rs2740 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80737

TC  changed:

   What|Removed |Added

 CC||rs2740 at gmail dot com

--- Comment #1 from TC  ---
#include 
#include 

std::variant a, b(a);

In file included from main.cpp:1:0:
/usr/local/include/c++/7.1.0/variant: In instantiation of 'struct
std::__detail::__variant::__accepted_index':
/usr/local/include/c++/7.1.0/variant:911:26:   required from 'constexpr const
size_t std::variant::__accepted_index'
/usr/local/include/c++/7.1.0/variant:940:6:   required by substitution of
'template constexpr std::variant::variant(_Tp&&)
[with _Tp = std::variant&;  = ]'
main.cpp:4:30:   required from here
/usr/local/include/c++/7.1.0/variant:559:49: error: no matching function for
call to
'std::__detail::__variant::__overload_set::_S_fun(std::variant&)'
   decltype(__overload_set<_Types...>::_S_fun(std::declval<_Tp>()),
~^
/usr/local/include/c++/7.1.0/variant:541:58: note: candidate: static
std::integral_constant
std::__detail::__variant::__overload_set<_First, _Rest ...>::_S_fun(_First)
[with _First = std::any; _Rest = {}]
   static integral_constant _S_fun(_First);
  ^~
/usr/local/include/c++/7.1.0/variant:541:58: note:   no known conversion for
argument 1 from 'std::variant' to 'std::any'
/usr/local/include/c++/7.1.0/variant:535:19: note: candidate: static void
std::__detail::__variant::__overload_set<_Types>::_S_fun() [with _Types = {}]
 { static void _S_fun(); };
   ^~
/usr/local/include/c++/7.1.0/variant:535:19: note:   candidate expects 0
arguments, 1 provided
/usr/local/include/c++/7.1.0/variant:559:49: error: no matching function for
call to
'std::__detail::__variant::__overload_set::_S_fun(std::variant&)'
   decltype(__overload_set<_Types...>::_S_fun(std::declval<_Tp>()),
~^
/usr/local/include/c++/7.1.0/variant:541:58: note: candidate: static
std::integral_constant
std::__detail::__variant::__overload_set<_First, _Rest ...>::_S_fun(_First)
[with _First = std::any; _Rest = {}]
   static integral_constant _S_fun(_First);
  ^~
/usr/local/include/c++/7.1.0/variant:541:58: note:   no known conversion for
argument 1 from 'std::variant' to 'std::any'
/usr/local/include/c++/7.1.0/variant:535:19: note: candidate: static void
std::__detail::__variant::__overload_set<_Types>::_S_fun() [with _Types = {}]
 { static void _S_fun(); };
   ^~
/usr/local/include/c++/7.1.0/variant:535:19: note:   candidate expects 0
arguments, 1 provided
/usr/local/include/c++/7.1.0/variant:559:49: error: no matching function for
call to
'std::__detail::__variant::__overload_set::_S_fun(std::variant&)'
   decltype(__overload_set<_Types...>::_S_fun(std::declval<_Tp>()),
~^
/usr/local/include/c++/7.1.0/variant:541:58: note: candidate: static
std::integral_constant
std::__detail::__variant::__overload_set<_First, _Rest ...>::_S_fun(_First)
[with _First = std::any; _Rest = {}]
   static integral_constant _S_fun(_First);
  ^~
/usr/local/include/c++/7.1.0/variant:541:58: note:   no known conversion for
argument 1 from 'std::variant' to 'std::any'
/usr/local/include/c++/7.1.0/variant:535:19: note: candidate: static void
std::__detail::__variant::__overload_set<_Types>::_S_fun() [with _Types = {}]
 { static void _S_fun(); };
   ^~
/usr/local/include/c++/7.1.0/variant:535:19: note:   candidate expects 0
arguments, 1 provided
/usr/local/include/c++/7.1.0/variant: In instantiation of 'constexpr const
size_t std::__detail::__variant::__accepted_index::value':
/usr/local/include/c++/7.1.0/variant:911:26:   required from 'constexpr const
size_t std::variant::__accepted_index'
/usr/local/include/c++/7.1.0/variant:940:6:   required by substitution of
'template constexpr std::variant::variant(_Tp&&)
[with _Tp = std::variant&;  = ]'
main.cpp:4:30:   required from here
/usr/local/include/c++/7.1.0/variant:564:12: error: no matching function for
call to
'std::__detail::__variant::__overload_set::_S_fun(std::variant&)'
  - decltype(__overload_set<_Types...>::
 ~~~
  _S_fun(std::declval<_Tp>()))::value;
  ~~^
/usr/local/include/c++/7.1.0/variant:541:58: note: candidate: static
std::integral_constant
std::__detail::__variant::__overload_set<_First, _Rest