[Bug libstdc++/90220] std::any_cast misbehaves for function and array types

2019-05-23 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90220

Jonathan Wakely  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #9 from Jonathan Wakely  ---
Fixed for 7.5 and 8.4 as well.

[Bug libstdc++/90220] std::any_cast misbehaves for function and array types

2019-05-23 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90220

--- Comment #10 from Jonathan Wakely  ---
Author: redi
Date: Thu May 23 15:08:58 2019
New Revision: 271565

URL: https://gcc.gnu.org/viewcvs?rev=271565=gcc=rev
Log:
PR libstdc++/90220 Fix any_cast for non-object types

Backport from mainline
2019-04-24  Jonathan Wakely  

PR libstdc++/90220 (partial)
* include/std/any (any_cast(any*), any_cast(const any*)): Do
not attempt ill-formed static_cast to pointers to non-object types.
* testsuite/20_util/any/misc/any_cast.cc: Test std::any_cast with
function types.

Backport from mainline
2019-04-24  Jonathan Wakely  

PR libstdc++/90220
* include/std/any (__any_caster): Use remove_cv_t instead of decay_t.
Avoid a runtime check for types that can never be stored in std::any.
* testsuite/20_util/any/misc/any_cast.cc: Test std::any_cast with
array types.

Backport from mainline
2019-05-23  Jonathan Wakely  

PR libstdc++/90220
* include/experimental/any (__any_caster): Constrain to only be
callable for object types. Use remove_cv_t instead of decay_t.
If the type decays or isn't copy constructible, compare the manager
function to a dummy specialization.
(__any_caster): Add overload constrained for non-object types.
(any::_Manager_internal<_Op>): Add dummy specialization.
* testsuite/experimental/any/misc/any_cast.cc: Test function types
and array types.

Modified:
branches/gcc-7-branch/libstdc++-v3/ChangeLog
branches/gcc-7-branch/libstdc++-v3/include/experimental/any
branches/gcc-7-branch/libstdc++-v3/include/std/any
branches/gcc-7-branch/libstdc++-v3/testsuite/20_util/any/misc/any_cast.cc
   
branches/gcc-7-branch/libstdc++-v3/testsuite/experimental/any/misc/any_cast.cc

[Bug libstdc++/90220] std::any_cast misbehaves for function and array types

2019-05-23 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90220

--- Comment #8 from Jonathan Wakely  ---
Author: redi
Date: Thu May 23 14:49:15 2019
New Revision: 271561

URL: https://gcc.gnu.org/viewcvs?rev=271561=gcc=rev
Log:
PR libstdc++/90220 Fix any_cast for non-object types

Backport from mainline
2019-04-24  Jonathan Wakely  

PR libstdc++/90220 (partial)
* include/std/any (any_cast(any*), any_cast(const any*)): Do
not attempt ill-formed static_cast to pointers to non-object types.
* testsuite/20_util/any/misc/any_cast.cc: Test std::any_cast with
function types.

Backport from mainline
2019-04-24  Jonathan Wakely  

PR libstdc++/90220
* include/std/any (__any_caster): Use remove_cv_t instead of decay_t.
Avoid a runtime check for types that can never be stored in std::any.
* testsuite/20_util/any/misc/any_cast.cc: Test std::any_cast with
array types.

Backport from mainline
2019-05-23  Jonathan Wakely  

PR libstdc++/90220
* include/experimental/any (__any_caster): Constrain to only be
callable for object types. Use remove_cv_t instead of decay_t.
If the type decays or isn't copy constructible, compare the manager
function to a dummy specialization.
(__any_caster): Add overload constrained for non-object types.
(any::_Manager_internal<_Op>): Add dummy specialization.
* testsuite/experimental/any/misc/any_cast.cc: Test function types
and array types.

Modified:
branches/gcc-8-branch/libstdc++-v3/ChangeLog
branches/gcc-8-branch/libstdc++-v3/include/experimental/any
branches/gcc-8-branch/libstdc++-v3/include/std/any
branches/gcc-8-branch/libstdc++-v3/testsuite/20_util/any/misc/any_cast.cc
   
branches/gcc-8-branch/libstdc++-v3/testsuite/experimental/any/misc/any_cast.cc

[Bug libstdc++/90220] std::any_cast misbehaves for function and array types

2019-05-23 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90220

--- Comment #7 from Jonathan Wakely  ---
Author: redi
Date: Thu May 23 14:18:13 2019
New Revision: 271558

URL: https://gcc.gnu.org/viewcvs?rev=271558=gcc=rev
Log:
PR libstdc++/90220 fix experimental::any_cast for non-object types

This corresponds to the fixes done for std::any_cast, but has to be done
without if-constexpr. The dummy specialization of _Manager_internal<_Op>
is used to avoid instantiating the real _Manager_internal::_S_manage
function just to compare its address.

Backport from mainline
2019-05-23  Jonathan Wakely  

PR libstdc++/90220
* include/experimental/any (__any_caster): Constrain to only be
callable for object types. Use remove_cv_t instead of decay_t.
If the type decays or isn't copy constructible, compare the manager
function to a dummy specialization.
(__any_caster): Add overload constrained for non-object types.
(any::_Manager_internal<_Op>): Add dummy specialization.
* testsuite/experimental/any/misc/any_cast.cc: Test function types
and array types.

Modified:
branches/gcc-9-branch/libstdc++-v3/ChangeLog
branches/gcc-9-branch/libstdc++-v3/include/experimental/any
   
branches/gcc-9-branch/libstdc++-v3/testsuite/experimental/any/misc/any_cast.cc

[Bug libstdc++/90220] std::any_cast misbehaves for function and array types

2019-05-23 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90220

--- Comment #6 from Jonathan Wakely  ---
Author: redi
Date: Thu May 23 13:39:06 2019
New Revision: 271556

URL: https://gcc.gnu.org/viewcvs?rev=271556=gcc=rev
Log:
PR libstdc++/90220 fix experimental::any_cast for non-object types

This corresponds to the fixes done for std::any_cast, but has to be done
without if-constexpr. The dummy specialization of _Manager_internal<_Op>
is used to avoid instantiating the real _Manager_internal::_S_manage
function just to compare its address.

PR libstdc++/90220
* include/experimental/any (__any_caster): Constrain to only be
callable for object types. Use remove_cv_t instead of decay_t.
If the type decays or isn't copy constructible, compare the manager
function to a dummy specialization.
(__any_caster): Add overload constrained for non-object types.
(any::_Manager_internal<_Op>): Add dummy specialization.
* testsuite/experimental/any/misc/any_cast.cc: Test function types
and array types.

Modified:
trunk/libstdc++-v3/ChangeLog
trunk/libstdc++-v3/include/experimental/any
trunk/libstdc++-v3/testsuite/experimental/any/misc/any_cast.cc

[Bug libstdc++/90220] std::any_cast misbehaves for function and array types

2019-04-24 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90220

Jonathan Wakely  changed:

   What|Removed |Added

   Target Milestone|--- |7.5

--- Comment #5 from Jonathan Wakely  ---
Both examples are fixed on trunk. I plan to backport the fixes.

[Bug libstdc++/90220] std::any_cast misbehaves for function and array types

2019-04-24 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90220

--- Comment #4 from Jonathan Wakely  ---
Author: redi
Date: Wed Apr 24 15:17:43 2019
New Revision: 270547

URL: https://gcc.gnu.org/viewcvs?rev=270547=gcc=rev
Log:
PR libstdc++/90220 Fix std::any_cast for array types

Although the std::any constructors use decay_t to determine the type of
the contained value, std::any_cast should use the un-decayed type (and
so always fail for function and array types that decay to pointers).

Using remove_cv_t is correct, because the condition for std::any_cast
to return non-null is operand.type() == typeid(T) and typeid ignores
top-level cv-qualifiers.

PR libstdc++/90220
* include/std/any (__any_caster): Use remove_cv_t instead of decay_t.
Avoid a runtime check for types that can never be stored in std::any.
* testsuite/20_util/any/misc/any_cast.cc: Test std::any_cast with
array types.

Modified:
trunk/libstdc++-v3/ChangeLog
trunk/libstdc++-v3/include/std/any
trunk/libstdc++-v3/testsuite/20_util/any/misc/any_cast.cc

[Bug libstdc++/90220] std::any_cast misbehaves for function and array types

2019-04-24 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90220

--- Comment #3 from Jonathan Wakely  ---
Patch for the second bit posted:
https://gcc.gnu.org/ml/gcc-patches/2019-04/msg00927.html

[Bug libstdc++/90220] std::any_cast misbehaves for function and array types

2019-04-24 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90220

--- Comment #2 from Jonathan Wakely  ---
The first example compiles OK on trunk now, the second isn't fixed yet.

[Bug libstdc++/90220] std::any_cast misbehaves for function and array types

2019-04-24 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90220

--- Comment #1 from Jonathan Wakely  ---
Author: redi
Date: Wed Apr 24 09:46:07 2019
New Revision: 270538

URL: https://gcc.gnu.org/viewcvs?rev=270538=gcc=rev
Log:
PR libstdc++/90220 Fix std::any_cast for function pointers

PR libstdc++/90220 (partial)
* include/std/any (any_cast(any*), any_cast(const any*)): Do
not attempt ill-formed static_cast to pointers to non-object types.
* testsuite/20_util/any/misc/any_cast.cc: Test std::any_cast with
function types.

Modified:
trunk/libstdc++-v3/ChangeLog
trunk/libstdc++-v3/include/std/any
trunk/libstdc++-v3/testsuite/20_util/any/misc/any_cast.cc

[Bug libstdc++/90220] std::any_cast misbehaves for function and array types

2019-04-24 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90220

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2019-04-24
   Assignee|unassigned at gcc dot gnu.org  |redi at gcc dot gnu.org
 Ever confirmed|0   |1