public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "frankhb1989 at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/111357] New: __integer_pack fails to work with values of dependent type convertible to integers
Date: Sun, 10 Sep 2023 02:16:21 +0000	[thread overview]
Message-ID: <bug-111357-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 111357
           Summary: __integer_pack fails to work with values of dependent
                    type convertible to integers
           Product: gcc
           Version: 13.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: frankhb1989 at gmail dot com
  Target Milestone: ---

Case:

#include <cstddef>
#include <type_traits>
#include <tuple>

using std::size_t;
#if __cpp_lib_integer_sequence >= 201304L
using std::index_sequence;
using std::make_index_sequence;
#else
template<size_t... V>
struct index_sequence
{};

template<class>
struct succ;

template<size_t... V>
struct succ<index_sequence<V...>>
{
        using type = index_sequence<V..., sizeof...(V)>;
};

template<size_t N>
struct iseq
{
        using type = typename succ<typename iseq<N - 1>::type>::type;
};

template<>
struct iseq<0>
{
        using type = index_sequence<>;
};

template<size_t N>
using make_index_sequence = typename iseq<N>::type;
#endif


template<size_t... V>
void g(index_sequence<V...>)
{}

template<typename T>
struct R
{
        using S = make_index_sequence<std::tuple_size<std::tuple<T>>{}>;

        R() noexcept(noexcept(g(S())))
        {}
};

int main()
{
        R<int>();
}


Output of x86-64 gcc 13.2 (Compiler #1)
<source>: In instantiation of 'R<T>::R() [with T = int]':
<source>:55:9:   required from here
<source>:49:33: error: argument to '__integer_pack' must be between 0 and
268435452
   49 |         R() noexcept(noexcept(g(S())))
      |                                 ^~~

This should work as -std=c++11 which uses a naive implementation of
make_index_sequence here.

I mark it as a libstdc++ bug of conformance for the case. The root cause seems
a bug of the implementation in the frontend, but I'm not that sure, because the
document of __integer_pack does not mention such cases explicitly. (The error
message here is obviously confusing, though.)

             reply	other threads:[~2023-09-10  2:16 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-10  2:16 frankhb1989 at gmail dot com [this message]
2023-09-10  3:33 ` [Bug c++/111357] " pinskia at gcc dot gnu.org
2023-09-10  3:52 ` [Bug c++/111357] __integer_pack fails to work with values of dependent type convertible to integers in noexcept context pinskia at gcc dot gnu.org
2023-09-10  3:56 ` [Bug c++/111357] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
2023-09-11  8:54 ` redi at gcc dot gnu.org
2023-09-11 13:39 ` jason at gcc dot gnu.org
2023-09-11 13:43 ` jakub at gcc dot gnu.org
2023-09-12 17:27 ` cvs-commit at gcc dot gnu.org
2023-09-14 13:27 ` cvs-commit at gcc dot gnu.org
2023-09-14 13:39 ` cvs-commit at gcc dot gnu.org
2023-09-14 13:40 ` cvs-commit at gcc dot gnu.org
2023-09-14 13:42 ` cvs-commit at gcc dot gnu.org
2023-09-22 14:36 ` cvs-commit at gcc dot gnu.org
2023-09-23  7:41 ` jakub at gcc dot gnu.org
2024-01-19 18:35 ` cvs-commit at gcc dot gnu.org
2024-01-19 19:29 ` jason 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-111357-4@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).