public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/104242] New: Class with constructor from std::any is not copyable
@ 2022-01-26 12:51 fchelnokov at gmail dot com
2022-01-26 12:52 ` [Bug c++/104242] " fchelnokov at gmail dot com
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: fchelnokov at gmail dot com @ 2022-01-26 12:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104242
Bug ID: 104242
Summary: Class with constructor from std::any is not copyable
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: fchelnokov at gmail dot com
Target Milestone: ---
The following code
```
#include <any>
#include <type_traits>
struct A {
A(const A&) = default;
explicit A(std::any value);
};
static_assert(std::is_copy_constructible_v<A>);
```
is accepted by GCC 11, but rejected by GCC trunk. Demo:
https://gcc.godbolt.org/z/sWTbhqE6c
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/104242] Class with constructor from std::any is not copyable
2022-01-26 12:51 [Bug c++/104242] New: Class with constructor from std::any is not copyable fchelnokov at gmail dot com
@ 2022-01-26 12:52 ` fchelnokov at gmail dot com
2022-01-26 13:06 ` [Bug c++/104242] [12 Regression] " rguenth at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: fchelnokov at gmail dot com @ 2022-01-26 12:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104242
--- Comment #1 from Fedor Chelnokov <fchelnokov at gmail dot com> ---
The error message is
invalid use of incomplete type 'std::__conditional_t<true,
std::is_copy_constructible<A>, std::__not_<std::integral_constant<bool, false>
> >' {aka 'struct std::is_copy_constructible<A>'}
...
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/104242] [12 Regression] Class with constructor from std::any is not copyable
2022-01-26 12:51 [Bug c++/104242] New: Class with constructor from std::any is not copyable fchelnokov at gmail dot com
2022-01-26 12:52 ` [Bug c++/104242] " fchelnokov at gmail dot com
@ 2022-01-26 13:06 ` rguenth at gcc dot gnu.org
2022-01-26 19:03 ` [Bug libstdc++/104242] " pinskia at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-26 13:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104242
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Summary|Class with constructor from |[12 Regression] Class with
|std::any is not copyable |constructor from std::any
| |is not copyable
Target Milestone|--- |12.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/104242] [12 Regression] Class with constructor from std::any is not copyable
2022-01-26 12:51 [Bug c++/104242] New: Class with constructor from std::any is not copyable fchelnokov at gmail dot com
2022-01-26 12:52 ` [Bug c++/104242] " fchelnokov at gmail dot com
2022-01-26 13:06 ` [Bug c++/104242] [12 Regression] " rguenth at gcc dot gnu.org
@ 2022-01-26 19:03 ` pinskia at gcc dot gnu.org
2022-01-26 19:05 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-26 19:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104242
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note Clang's error message might be more helpfull:
In file included from <source>:2:
In file included from
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.1/../../../../include/c++/12.0.1/any:39:
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.1/../../../../include/c++/12.0.1/type_traits:168:14:
error: base class has incomplete type
: public __conditional_t<_B1::value, _B2, _B1>
~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.1/../../../../include/c++/12.0.1/type_traits:2244:36:
note: in instantiation of template class
'std::__and_<std::__not_<std::integral_constant<bool, false>>,
std::is_copy_constructible<A>>' requested here
using _Require = __enable_if_t<__and_<_Cond...>::value>;
^
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.1/../../../../include/c++/12.0.1/any:188:19:
note: in instantiation of template type alias '_Require' requested here
typename = _Require<__not_<__is_in_place_type<_VTp>>,
^
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.1/../../../../include/c++/12.0.1/any:190:7:
note: in instantiation of default argument for 'any<const A &, A,
std::any::_Manager_internal<A>>' required here
any(_Tp&& __value)
^~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.1/../../../../include/c++/12.0.1/type_traits:971:54:
note: while substituting deduced template arguments into function template
'any' [with _Tp = const A &, _VTp = (no value), _Mgr = (no value), $3 = (no
value)]
: public __bool_constant<__is_constructible(_Tp, _Args...)>
^
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.1/../../../../include/c++/12.0.1/type_traits:1003:14:
note: in instantiation of template class 'std::__is_constructible_impl<A, const
A &>' requested here
: public __is_constructible_impl<_Tp, const _Tp&>
^
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.1/../../../../include/c++/12.0.1/type_traits:1010:14:
note: in instantiation of template class 'std::__is_copy_constructible_impl<A,
true>' requested here
: public __is_copy_constructible_impl<_Tp>
^
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.1/../../../../include/c++/12.0.1/type_traits:3205:5:
note: in instantiation of template class 'std::is_copy_constructible<A>'
requested here
is_copy_constructible<_Tp>::value;
^
<source>:9:20: note: in instantiation of variable template specialization
'std::is_copy_constructible_v<A>' requested here
static_assert(std::is_copy_constructible_v<A>);
^
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.1/../../../../include/c++/12.0.1/type_traits:1009:12:
note: definition of 'std::is_copy_constructible<A>' is not complete until the
closing '}'
struct is_copy_constructible
^
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/104242] [12 Regression] Class with constructor from std::any is not copyable
2022-01-26 12:51 [Bug c++/104242] New: Class with constructor from std::any is not copyable fchelnokov at gmail dot com
` (2 preceding siblings ...)
2022-01-26 19:03 ` [Bug libstdc++/104242] " pinskia at gcc dot gnu.org
@ 2022-01-26 19:05 ` pinskia at gcc dot gnu.org
2022-03-09 13:21 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-26 19:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104242
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2022-01-26
Status|UNCONFIRMED |NEW
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Most likely caused by r12-4190.
Confirmed.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/104242] [12 Regression] Class with constructor from std::any is not copyable
2022-01-26 12:51 [Bug c++/104242] New: Class with constructor from std::any is not copyable fchelnokov at gmail dot com
` (3 preceding siblings ...)
2022-01-26 19:05 ` pinskia at gcc dot gnu.org
@ 2022-03-09 13:21 ` rguenth at gcc dot gnu.org
2022-03-18 15:42 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-03-09 13:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104242
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/104242] [12 Regression] Class with constructor from std::any is not copyable
2022-01-26 12:51 [Bug c++/104242] New: Class with constructor from std::any is not copyable fchelnokov at gmail dot com
` (4 preceding siblings ...)
2022-03-09 13:21 ` rguenth at gcc dot gnu.org
@ 2022-03-18 15:42 ` cvs-commit at gcc dot gnu.org
2022-03-18 17:48 ` redi at gcc dot gnu.org
2023-06-23 12:56 ` cvs-commit at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-18 15:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104242
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:
https://gcc.gnu.org/g:7a42b1fa1a090ead96cc0f94a8060a9650c810d5
commit r12-7708-g7a42b1fa1a090ead96cc0f94a8060a9650c810d5
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Fri Mar 18 13:10:01 2022 +0000
libstdc++: Simplify constraints for std::any construction [PR104242]
Partially revert r12-4190-g6da36b7d0e43b6f9281c65c19a025d4888a25b2d
because using __and_<..., is_copy_constructible<T>> when T is incomplete
results in an error about deriving from is_copy_constructible<T> when
that is incomplete. I don't know how to fix that, so this simply
restores the previous constraint which worked in this case (even though
I think it's technically undefined to use is_copy_constructible<T> with
incomplete T). This doesn't restore exactly what we had before, but uses
the is_copy_constructible_v and __is_in_place_type_v variable templates
instead of the ::value member.
libstdc++-v3/ChangeLog:
PR libstdc++/104242
* include/std/any (any(T&&)): Revert change to constraints.
* testsuite/20_util/any/cons/104242.cc: New test.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/104242] [12 Regression] Class with constructor from std::any is not copyable
2022-01-26 12:51 [Bug c++/104242] New: Class with constructor from std::any is not copyable fchelnokov at gmail dot com
` (5 preceding siblings ...)
2022-03-18 15:42 ` cvs-commit at gcc dot gnu.org
@ 2022-03-18 17:48 ` redi at gcc dot gnu.org
2023-06-23 12:56 ` cvs-commit at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2022-03-18 17:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104242
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libstdc++/104242] [12 Regression] Class with constructor from std::any is not copyable
2022-01-26 12:51 [Bug c++/104242] New: Class with constructor from std::any is not copyable fchelnokov at gmail dot com
` (6 preceding siblings ...)
2022-03-18 17:48 ` redi at gcc dot gnu.org
@ 2023-06-23 12:56 ` cvs-commit at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-06-23 12:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104242
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:
https://gcc.gnu.org/g:5fc6b3a03355e1f77a7c38c0fa7afb0822ad954f
commit r11-10870-g5fc6b3a03355e1f77a7c38c0fa7afb0822ad954f
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Fri Mar 18 13:10:01 2022 +0000
libstdc++: Simplify constraints for std::any construction [PR104242]
Partially revert r12-4190-g6da36b7d0e43b6f9281c65c19a025d4888a25b2d
because using __and_<..., is_copy_constructible<T>> when T is incomplete
results in an error about deriving from is_copy_constructible<T> when
that is incomplete. I don't know how to fix that, so this simply
restores the previous constraint which worked in this case (even though
I think it's technically undefined to use is_copy_constructible<T> with
incomplete T). This doesn't restore exactly what we had before, but uses
the is_copy_constructible_v and __is_in_place_type_v variable templates
instead of the ::value member.
libstdc++-v3/ChangeLog:
PR libstdc++/104242
* include/std/any (any(T&&)): Revert change to constraints.
* testsuite/20_util/any/cons/104242.cc: New test.
(cherry picked from commit 7a42b1fa1a090ead96cc0f94a8060a9650c810d5)
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-06-23 12:56 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-26 12:51 [Bug c++/104242] New: Class with constructor from std::any is not copyable fchelnokov at gmail dot com
2022-01-26 12:52 ` [Bug c++/104242] " fchelnokov at gmail dot com
2022-01-26 13:06 ` [Bug c++/104242] [12 Regression] " rguenth at gcc dot gnu.org
2022-01-26 19:03 ` [Bug libstdc++/104242] " pinskia at gcc dot gnu.org
2022-01-26 19:05 ` pinskia at gcc dot gnu.org
2022-03-09 13:21 ` rguenth at gcc dot gnu.org
2022-03-18 15:42 ` cvs-commit at gcc dot gnu.org
2022-03-18 17:48 ` redi at gcc dot gnu.org
2023-06-23 12:56 ` cvs-commit at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).