From: Jakub Jelinek <jakub@redhat.com>
To: Jason Merrill <jason@redhat.com>
Cc: Andreas Schwab <schwab@suse.de>,
gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: Re: C++ PATCH to add __integer_pack built-in for std::make_integer_sequence (c++/80396)
Date: Wed, 24 May 2017 19:13:00 -0000 [thread overview]
Message-ID: <20170524191215.GP8499@tucnak> (raw)
In-Reply-To: <CADzB+2mLdxBk2Hw9Gw4S-GjM9ZmaT+u+cKStMD=nk0eFc29daQ@mail.gmail.com>
On Wed, May 24, 2017 at 02:47:08PM -0400, Jason Merrill wrote:
> On Wed, May 24, 2017 at 11:08 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> > On Wed, May 24, 2017 at 04:16:30PM +0200, Andreas Schwab wrote:
> >> FAIL: g++.dg/ext/integer-pack2.C -std=gnu++11 (test for excess errors)
> >> Excess errors:
> >> /daten/aranym/gcc/gcc-20170524/gcc/testsuite/g++.dg/ext/integer-pack2.C:10:48: error: overflow in constant expression [-fpermissive]
> >> /daten/aranym/gcc/gcc-20170524/gcc/testsuite/g++.dg/ext/integer-pack2.C:10:48: error: overflow in constant expression [-fpermissive]
> >
> > To be precise, it fails only on 32-bit targets.
>
> > If we at that point want some wider integer that when cast to int
> > is 0 (or small enough positive number?), shall we use something like
> > this, or say 1LL << (sizeof (int) * __CHAR_BIT__), or 2LL * INT_MIN,
> > something else?
>
> This is fine.
>
> > Do we need to include <limits.h>? Or can we replace
> > INT_MAX with __INT_MAX__?
>
> __INT_MAX__ sounds good.
>
> > Not sure about that -2147483650 for 16-bit int targets (perhaps the test can
> > be guarded with int32 effective target).
>
> Yes, restricting the test to int32 seems like the easiest fix.
Ok, I've committed this (also add something to avoid failing on hypothetical
64-bit int 64-bit long long target). Tested for both -m32 and -m64 on
x86_64-linux.
2017-05-24 Jakub Jelinek <jakub@redhat.com>
* g++.dg/ext/integer-pack2.C: Require int32 effective target.
Don't include limits.h.
(w): Conditionalize on long long wider than int. Use
1LL << (__SIZEOF_INT__ * __CHAR_BIT__) instead of
-9223372036854775808.
(x): Use __INT_MAX__ instead of INT_MAX.
--- gcc/testsuite/g++.dg/ext/integer-pack2.C.jj 2017-05-24 11:59:01.000000000 +0200
+++ gcc/testsuite/g++.dg/ext/integer-pack2.C 2017-05-24 21:07:02.000000000 +0200
@@ -1,12 +1,12 @@
-// { dg-do compile { target c++11 } }
+// { dg-do compile { target { c++11 && int32 } } }
// { dg-options -w }
-#include <limits.h>
-
template<typename T, T...> struct integer_sequence { };
template<typename T, T num>
using make_integer_sequence = integer_sequence<T, __integer_pack(num)...>; // { dg-error "argument" }
-make_integer_sequence<int, -9223372036854775808> w;
-make_integer_sequence<int, INT_MAX> x; // { dg-message "required" }
+#if __SIZEOF_LONG_LONG__ > __SIZEOF_INT__
+make_integer_sequence<int, 1LL << (__SIZEOF_INT__ * __CHAR_BIT__)> w;
+#endif
+make_integer_sequence<int, __INT_MAX__> x; // { dg-message "required" }
make_integer_sequence<int, -2147483650> y; // { dg-message "required" }
Jakub
prev parent reply other threads:[~2017-05-24 19:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-23 20:27 Jason Merrill
2017-05-24 14:18 ` Andreas Schwab
2017-05-24 15:17 ` Jakub Jelinek
2017-05-24 18:50 ` Jason Merrill
2017-05-24 19:13 ` Jakub Jelinek [this message]
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=20170524191215.GP8499@tucnak \
--to=jakub@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
--cc=schwab@suse.de \
/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).