This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH to add __integer_pack built-in for std::make_integer_sequence (c++/80396)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: Andreas Schwab <schwab at suse dot de>, gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 24 May 2017 21:12:15 +0200
- Subject: Re: C++ PATCH to add __integer_pack built-in for std::make_integer_sequence (c++/80396)
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5F6EF80C2B
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5F6EF80C2B
- References: <CADzB+2mZwSaHLOXUGAdf06dfck2af9cg1Vp7-6nCGsHVMDJ=Fg@mail.gmail.com> <mvmefvewda9.fsf@suse.de> <20170524150823.GK8499@tucnak> <CADzB+2mLdxBk2Hw9Gw4S-GjM9ZmaT+u+cKStMD=nk0eFc29daQ@mail.gmail.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot 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