public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/71579] type_traits miss checks for type completeness in some traits
Date: Thu, 01 Sep 2022 21:58:34 +0000	[thread overview]
Message-ID: <bug-71579-4-yMuQttMIU5@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-71579-4@http.gcc.gnu.org/bugzilla/>

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.

  parent reply	other threads:[~2022-09-01 21:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-71579-4-yMuQttMIU5@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).