public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/71579] type_traits miss checks for type completeness in some traits
       [not found] <bug-71579-4@http.gcc.gnu.org/bugzilla/>
@ 2020-05-07 11:56 ` jakub at gcc dot gnu.org
  2020-06-09 14:18 ` kuzniar95 at o2 dot pl
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-05-07 11:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71579

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.0                        |10.2

--- Comment #14 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 10.1 has been released.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/71579] type_traits miss checks for type completeness in some traits
       [not found] <bug-71579-4@http.gcc.gnu.org/bugzilla/>
  2020-05-07 11:56 ` [Bug libstdc++/71579] type_traits miss checks for type completeness in some traits jakub at gcc dot gnu.org
@ 2020-06-09 14:18 ` kuzniar95 at o2 dot pl
  2020-07-23  6:52 ` rguenth at gcc dot gnu.org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: kuzniar95 at o2 dot pl @ 2020-06-09 14:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71579

kuzniar95 at o2 dot pl changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kuzniar95 at o2 dot pl

--- Comment #15 from kuzniar95 at o2 dot pl ---
The related patch is a reason for
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95606. May I kindly ask you to
look into that?

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/71579] type_traits miss checks for type completeness in some traits
       [not found] <bug-71579-4@http.gcc.gnu.org/bugzilla/>
  2020-05-07 11:56 ` [Bug libstdc++/71579] type_traits miss checks for type completeness in some traits jakub at gcc dot gnu.org
  2020-06-09 14:18 ` kuzniar95 at o2 dot pl
@ 2020-07-23  6:52 ` rguenth at gcc dot gnu.org
  2020-07-23 11:30 ` redi at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-07-23  6:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71579

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.2                        |10.3

--- Comment #16 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 10.2 is released, adjusting target milestone.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/71579] type_traits miss checks for type completeness in some traits
       [not found] <bug-71579-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2020-07-23  6:52 ` rguenth at gcc dot gnu.org
@ 2020-07-23 11:30 ` redi at gcc dot gnu.org
  2020-08-19 11:25 ` cvs-commit at gcc dot gnu.org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2020-07-23 11:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71579

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.3                        |---

--- Comment #17 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Unsetting the milestone, any further changes will be on trunk only.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/71579] type_traits miss checks for type completeness in some traits
       [not found] <bug-71579-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2020-07-23 11:30 ` redi at gcc dot gnu.org
@ 2020-08-19 11:25 ` cvs-commit at gcc dot gnu.org
  2020-09-24 17:51 ` cvs-commit at gcc dot gnu.org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-08-19 11:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71579

--- Comment #18 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:69f571ffc513b689fa26e4c9fceba17c2c989ab3

commit r11-2759-g69f571ffc513b689fa26e4c9fceba17c2c989ab3
Author: Antony Polukhin <antoshkka@gmail.com>
Date:   Wed Aug 19 12:10:57 2020 +0100

    libstdc++: assert that type traits are not misused with incomplete types
[PR 71579]

    libstdc++-v3/ChangeLog:

    2020-08-19  Antony Polukhin  <antoshkka@gmail.com>

            PR libstdc++/71579
            * include/std/type_traits (invoke_result, is_nothrow_invocable_r)
            Add static_asserts to make sure that the argument of the type
            trait is not misused with incomplete types.
            (is_swappable_with, is_nothrow_swappable_with): Add static_asserts
            to make sure that the first and second arguments of the type trait
            are not misused with incomplete types.
            * testsuite/20_util/invoke_result/incomplete_neg.cc: New test.
            * testsuite/20_util/is_nothrow_invocable/incomplete_neg.cc: New
test.
            * testsuite/20_util/is_nothrow_swappable/incomplete_neg.cc: New
test.
            * testsuite/20_util/is_nothrow_swappable_with/incomplete_neg.cc:
New
            test.
            * testsuite/20_util/is_swappable_with/incomplete_neg.cc: New test.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/71579] type_traits miss checks for type completeness in some traits
       [not found] <bug-71579-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2020-08-19 11:25 ` cvs-commit at gcc dot gnu.org
@ 2020-09-24 17:51 ` cvs-commit at gcc dot gnu.org
  2022-09-01 21:58 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-24 17:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71579

--- Comment #19 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:c1fc9f6e10e646f01194c8f150affbc1cfbc404a

commit r11-3442-gc1fc9f6e10e646f01194c8f150affbc1cfbc404a
Author: Antony Polukhin <antoshkka@gmail.com>
Date:   Thu Sep 24 18:51:37 2020 +0100

    libstdc++: assert that type traits are not misused with incomplete types
[PR 71579]

    libstdc++-v3/ChangeLog:

            PR libstdc++/71579
            * include/std/type_traits (invoke_result, is_invocable)
            (is_invocable_r, is_nothrow_invocable, is_nothrow_invocable_r):
            Add static_asserts to make sure that the arguments of the type
            traits are not misused with incomplete types.
            * testsuite/20_util/invoke_result/incomplete_args_neg.cc: New test.
            * testsuite/20_util/is_invocable/incomplete_args_neg.cc: New test.
            * testsuite/20_util/is_invocable/incomplete_neg.cc: New test.
            * testsuite/20_util/is_nothrow_invocable/incomplete_args_neg.cc:
            New test.
            * testsuite/20_util/is_nothrow_invocable/incomplete_neg.cc: Check
            for error on incomplete type usage in trait.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/71579] type_traits miss checks for type completeness in some traits
       [not found] <bug-71579-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2020-09-24 17:51 ` cvs-commit at gcc dot gnu.org
@ 2022-09-01 21:58 ` redi at gcc dot gnu.org
  2022-09-01 22:00 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2022-09-01 21:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71579

--- Comment #20 from Jonathan Wakely <redi at gcc dot gnu.org> ---
  template<typename _Tp>
    struct is_standard_layout
    : public integral_constant<bool, __is_standard_layout(_Tp)>
    {
      static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
        "template argument must be a complete class or an unbounded array");
    };

This check is wrong. It passes for Incomplete[] but that's not valid for the
trait. The precondition is: "remove_all_extents_t<T> shall be a complete type
or cv void."

The __is_standard_layout built-in gets it right:

/usr/include/c++/12/type_traits:743:38: error: invalid use of incomplete type
‘class Incomplete’

We have the same problem for is_trivial, is_trivially_copyable, is_pod,
is_literal_type.

I think we should remove the checks from those traits and just rely on the
compiler to diagnose it.

Maybe we should consider dropping all the static assertions from traits that
are implemented using a compiler built-in. The __is_constructible(T, Args...)
built-in already checks the precondition, so we're just doing unnecessary work
to repeat that check using __is_complete_or_unbounded.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/71579] type_traits miss checks for type completeness in some traits
       [not found] <bug-71579-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2022-09-01 21:58 ` redi at gcc dot gnu.org
@ 2022-09-01 22:00 ` redi at gcc dot gnu.org
  2022-09-02  6:03 ` antoshkka at gmail dot com
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2022-09-01 22:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71579

--- Comment #21 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The precondition for has_virtual_destructor is: "If T is a non-union class
type, T shall be a complete type." Our type trait and the
__has_virtual_destructor built-in both seem to get this wrong, rejecting
Incomplete[2], which is not a class type, and so doesn't need to be complete
(or maybe the precondition is wrong and there's a library defect?)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/71579] type_traits miss checks for type completeness in some traits
       [not found] <bug-71579-4@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2022-09-01 22:00 ` redi at gcc dot gnu.org
@ 2022-09-02  6:03 ` antoshkka at gmail dot com
  2022-09-02 10:48 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: antoshkka at gmail dot com @ 2022-09-02  6:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71579

--- Comment #22 from Antony Polukhin <antoshkka at gmail dot com> ---
> Maybe we should consider dropping all the static assertions from traits that are implemented using a compiler built-in.

Sounds like the right thing to do.

> Our type trait and the __has_virtual_destructor built-in both seem to get this wrong, rejecting Incomplete[2], which is not a class type, and so doesn't need to be complete (or maybe the precondition is wrong and there's a library defect?)

The library precondition seems right. As I read it, the trait just checks for
`virtual` on the destructor. If there's no destructor - it is fine, no
`virtual` on it.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/71579] type_traits miss checks for type completeness in some traits
       [not found] <bug-71579-4@http.gcc.gnu.org/bugzilla/>
                   ` (8 preceding siblings ...)
  2022-09-02  6:03 ` antoshkka at gmail dot com
@ 2022-09-02 10:48 ` redi at gcc dot gnu.org
  2022-09-05 17:14 ` redi at gcc dot gnu.org
  2023-05-26 18:01 ` redi at gcc dot gnu.org
  11 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2022-09-02 10:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71579

--- Comment #23 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Yes, that's my reading of it. I need to check what other compilers do for
__has_virtual_destructor and check the docs. Maybe libstdc++ should only use it
for class types.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/71579] type_traits miss checks for type completeness in some traits
       [not found] <bug-71579-4@http.gcc.gnu.org/bugzilla/>
                   ` (9 preceding siblings ...)
  2022-09-02 10:48 ` redi at gcc dot gnu.org
@ 2022-09-05 17:14 ` redi at gcc dot gnu.org
  2023-05-26 18:01 ` redi at gcc dot gnu.org
  11 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2022-09-05 17:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71579

--- Comment #24 from Jonathan Wakely <redi at gcc dot gnu.org> ---
See PR 106838 for the __has_virtual_destructor bug.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/71579] type_traits miss checks for type completeness in some traits
       [not found] <bug-71579-4@http.gcc.gnu.org/bugzilla/>
                   ` (10 preceding siblings ...)
  2022-09-05 17:14 ` redi at gcc dot gnu.org
@ 2023-05-26 18:01 ` redi at gcc dot gnu.org
  11 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2023-05-26 18:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71579

--- Comment #25 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Some missing completeness checks:

std::assignable<int, Incomplete>
We don't enforce precondition that both types are complete types, cv void, or
arrays of unknown bound. Filed as PR c++/109997

std::common_type<int, Incomplete>
Our impl is SFINAE-friendly, but the standard has a precondition that all types
in the pack are complete, cv void, or array of unknown bound.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-05-26 18:02 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-71579-4@http.gcc.gnu.org/bugzilla/>
2020-05-07 11:56 ` [Bug libstdc++/71579] type_traits miss checks for type completeness in some traits jakub at gcc dot gnu.org
2020-06-09 14:18 ` kuzniar95 at o2 dot pl
2020-07-23  6:52 ` rguenth at gcc dot gnu.org
2020-07-23 11:30 ` redi at gcc dot gnu.org
2020-08-19 11:25 ` cvs-commit at gcc dot gnu.org
2020-09-24 17:51 ` cvs-commit at gcc dot gnu.org
2022-09-01 21:58 ` redi at gcc dot gnu.org
2022-09-01 22:00 ` redi at gcc dot gnu.org
2022-09-02  6:03 ` antoshkka at gmail dot com
2022-09-02 10:48 ` redi at gcc dot gnu.org
2022-09-05 17:14 ` redi at gcc dot gnu.org
2023-05-26 18:01 ` redi 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).