[Bug libstdc++/91807] New: [Regression] std::variant with multiple identical types assignment fail

2019-09-18 Thread raplonu.jb at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91807

Bug ID: 91807
   Summary: [Regression] std::variant with multiple identical
types assignment fail
   Product: gcc
   Version: 9.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: raplonu.jb at gmail dot com
  Target Milestone: ---

Created attachment 46895
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46895&action=edit
preprocessed file

Repro:
#include 

struct me_data {
me_data() = default;

me_data(const me_data &) {};
me_data(me_data &&) noexcept {};
me_data& operator=(const me_data &) = default;
};

int main() {
std::variant v1, v2;

v2 = v1;
}

Compiles with 8. Breaks with 9 (see bellow) and 10.0.0 201 (on wandbox :
https://wandbox.org/permlink/3GZeJzWMlElIgqGd ):

In file included from main.cpp:1:
/usr/include/c++/9/variant: In instantiation of
‘std::__detail::__variant::_Copy_assign_base<,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<, _Types>&) [with bool
 = false; _Types = {me_data, me_data}]::
mutable [with auto:3 = const me_data&; auto:4 = std::integral_constant]’:
/usr/include/c++/9/bits/invoke.h:60:36:   required from ‘constexpr _Res
std::__invoke_impl(std::__invoke_other, _Fn&&, _Args&& ...) [with _Res =
std::__detail::__variant::__variant_idx_cookie; _Fn =
std::__detail::__variant::_Copy_assign_base<,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<, _Types>&) [with bool
 = false; _Types = {me_data, me_data}]::;
_Args = {const me_data&, std::integral_constant}]’
/usr/include/c++/9/bits/invoke.h:95:40:   required from ‘constexpr typename
std::__invoke_result<_Functor, _ArgTypes>::type std::__invoke(_Callable&&,
_Args&& ...) [with _Callable =
std::__detail::__variant::_Copy_assign_base<,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<, _Types>&) [with bool
 = false; _Types = {me_data, me_data}]::;
_Args = {const me_data&, std::integral_constant};
typename std::__invoke_result<_Functor, _ArgTypes>::type =
std::__detail::__variant::__variant_idx_cookie]’
/usr/include/c++/9/variant:961:24:   required from ‘static constexpr
decltype(auto) std::__detail::__variant::__gen_vtable_impl<__same_return_types,
std::__detail::__variant::_Multi_array<_Result_type (*)(_Visitor, _Variants
...)>, std::tuple<_Variants ...>, std::integer_sequence >::__visit_invoke_impl(_Visitor&&, _Variants ...) [with bool
__same_return_types = true; _Result_type =
std::__detail::__variant::__variant_idx_cookie; _Visitor =
std::__detail::__variant::_Copy_assign_base<,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<, _Types>&) [with bool
 = false; _Types = {me_data, me_data}]::&&; _Variants = {const std::variant&}; long unsigned
int ...__indices = {0}]’
/usr/include/c++/9/variant:980:28:   required from ‘static constexpr
decltype(auto) std::__detail::__variant::__gen_vtable_impl<__same_return_types,
std::__detail::__variant::_Multi_array<_Result_type (*)(_Visitor, _Variants
...)>, std::tuple<_Variants ...>, std::integer_sequence >::__do_visit_invoke(_Visitor&&, _Variants ...) [with bool
__same_return_types = true; _Result_type =
std::__detail::__variant::__variant_idx_cookie; _Visitor =
std::__detail::__variant::_Copy_assign_base<,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<, _Types>&) [with bool
 = false; _Types = {me_data, me_data}]::&&; _Variants = {const std::variant&}; long unsigned
int ...__indices = {0}]’
/usr/include/c++/9/variant:996:28:   required from ‘static constexpr
decltype(auto) std::__detail::__variant::__gen_vtable_impl<__same_return_types,
std::__detail::__variant::_Multi_array<_Result_type (*)(_Visitor, _Variants
...)>, std::tuple<_Variants ...>, std::integer_sequence >::__visit_invoke(_Visitor&&, _Variants ...) [with bool
__same_return_types = true; _Result_type =
std::__detail::__variant::__variant_idx_cookie; _Visitor =
std::__detail::__variant::_Copy_assign_base<,
_Types>::operator=(const
std::__detail::__variant::_Copy_assign_base<, _Types>&) [with bool
 = false; _Types = {me_data, me_data}]::&&; _Variants = {const std::variant&}; long unsigned
int ...__indices = {0}]’
/usr/include/c++/9/variant:1005:28:   required from ‘static constexpr auto
std::__detail::__variant::__gen_vtable_impl<__same_return_types,
std::__detail::__variant::_Multi_array<_Result_type (*)(_Visitor, _Variants
...)>, std::tuple<_Variants ...>, std::integer_sequence >::_S_apply() [with bool __same_return_types = true;
_Result_type = std::__d

[Bug c++/111608] New: Cannot declare partial specialization after full specialization

2023-09-27 Thread raplonu.jb at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111608

Bug ID: 111608
   Summary: Cannot declare partial specialization after full
specialization
   Product: gcc
   Version: 13.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: raplonu.jb at gmail dot com
  Target Milestone: ---

The following code fails to compile with GCC 13.2 and under.

// primary template
template
struct X {
void f();
};

// definition of full template specialization before partial template
specialization
template<>
void X::f() {}

// partial template specialization declaration
template
struct X {
void f();
};

int main() {
X{}.f();
}

gcc give the following message:

error: partial specialization of 'struct X' after instantiation of 'struct
X

which seems incorrect since their have different levels of specialization.

[Bug c++/111608] Cannot declare partial specialization after full specialization

2023-09-28 Thread raplonu.jb at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111608

--- Comment #4 from Julien Bernard  ---
(In reply to Jonathan Wakely from comment #3)

I wasn't sure how to describe this issue, so my last sentence was probably
incorrect.

> I suspect this is covered by [temp.point] p7:
> 
> "If two different points of instantiation give a template specialization
> different meanings according to the one-definition rule (6.3), the program
> is ill-formed, no diagnostic required."

If I take this example:

// 1. primary template
template
struct X {
int f() { return 1; }
};

// 2. partial template specialization 
template
struct X {
int f() {return 2; }
};

// 3. full template specialization
template<>
struct X {
int f() { return 3; }
};

This program is well formed. In addition, the above 3. full template
specialization is equivalent to the following 4. implicit instantiation in the
sense they produce the same program (please, correct me if I'm wrong):

// 4. implicit instantiation
template<>
int X::f() { return 3; }

If I move 3. between 1. and 2., it still compiles but won't when 4. is between
1. and 2.

Here is a live demo with gcc, clang and msvc as a simple point of comparison.

https://godbolt.org/z/36aceTTb5

[Bug c++/116005] New: Class template argument deduction for alias templates error in C++20

2024-07-19 Thread raplonu.jb at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116005

Bug ID: 116005
   Summary: Class template argument deduction for alias templates
error in C++20
   Product: gcc
   Version: 14.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: raplonu.jb at gmail dot com
  Target Milestone: ---

Hi, the following code does not compile with gcc 14 & c++20.

template 
struct A {
template 
A(const std::vector &arr) {}
};

template 
A(std::vector const &) -> A;

template 
using B = A;

int main() {
const std::vector v;

B b{v};
}

It gives the following error message:

:19:10: error: class template argument deduction failed:
   19 | B b{v};
  |  ^
:19:10: error: no matching function for call to 'A(const
std::vector&)'
:11:1: note: candidate: 'template A(const
std::vector&)-> A requires  __is_deducible (B, A)'
   11 | A(std::vector const &) -> A;
  | ^
:11:1: note:   template argument deduction/substitution failed:
:19:10: note:   couldn't deduce template parameter 'T2'
   19 | B b{v};
  |  ^

I believe this code is valid and should compile.

Also, I notice with gcc 13 and above, it works if I replace `const T1` by
`std::add_const_t` in the deduction guide (or if I remove all const
keywords)

repro: https://godbolt.org/z/E5fE53oe1

Thanks for your time

[Bug c++/116005] Class template argument deduction for alias templates error in C++20

2024-07-19 Thread raplonu.jb at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116005

--- Comment #2 from Julien Bernard  ---
Which version of clang did you use ?

cppreference.com indicate that "class template argument deduction for alias
templates" support started with clang 19 which seems to be not released yet.

gcc introducted it with version 10.