On Tue, Jun 20, 2017 at 09:45:10PM +0200, Andreas Schwab wrote:
> On Jun 20 2017, Jason Merrill <ja...@redhat.com> wrote:
> 
> > On Tue, Jun 20, 2017 at 5:40 AM, Andreas Schwab <sch...@suse.de> wrote:
> >> FAIL: g++.dg/cpp0x/constexpr-cast.C  -std=c++11  (test for errors, line 10)
> >> FAIL: g++.dg/cpp0x/constexpr-cast.C  -std=c++11 (test for excess errors)
> >> FAIL: g++.dg/cpp0x/constexpr-cast.C  -std=c++14  (test for errors, line 10)
> >> FAIL: g++.dg/cpp0x/constexpr-cast.C  -std=c++14 (test for excess errors)
> >
> > I'm not seeing this.  Can you give more detail?
> 
> http://gcc.gnu.org/ml/gcc-testresults/2017-06/msg02172.html

It doesn't fail on LP64 targets, but does fail on ILP32,
on x86_64-linux can be reproduced with e.g.
make check-g++ RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} 
dg.exp=constexpr-cast.C'
The difference is that for LP64, 1 has different sizeof from void * and thus
you get one diagnostics, while on ILP32 int has the same precision as void
*.
So one gets:

/usr/src/gcc/gcc/testsuite/g++.dg/cpp0x/constexpr-cast.C:10:22: error: 
reinterpret_cast from integer to pointer
/usr/src/gcc/gcc/testsuite/g++.dg/cpp0x/constexpr-cast.C:11:22: error: 
'reinterpret_cast<void*>(1)' is not a constant expression
/usr/src/gcc/gcc/testsuite/g++.dg/cpp0x/constexpr-cast.C:24:26:   in constexpr 
expansion of 'f<int>()'
/usr/src/gcc/gcc/testsuite/g++.dg/cpp0x/constexpr-cast.C:24:27: error: value 
'4' of type 'int*' is not a constant expression
compiler exited with status 1
XFAIL: g++.dg/cpp0x/constexpr-cast.C  -std=c++11 bug c++/49171 (test for 
errors, line 8)
FAIL: g++.dg/cpp0x/constexpr-cast.C  -std=c++11  (test for errors, line 10)
PASS: g++.dg/cpp0x/constexpr-cast.C  -std=c++11  (test for errors, line 11)
PASS: g++.dg/cpp0x/constexpr-cast.C  -std=c++11  (test for errors, line 24)
FAIL: g++.dg/cpp0x/constexpr-cast.C  -std=c++11 (test for excess errors)
Excess errors:
/usr/src/gcc/gcc/testsuite/g++.dg/cpp0x/constexpr-cast.C:10:22: error: 
reinterpret_cast from integer to pointer

The following patch fixes it by allowing that wording too on the line 10.
Is this ok for trunk or do you have some other preference?

2017-06-21  Jakub Jelinek  <ja...@redhat.com>

        * g++.dg/cpp0x/constexpr-cast.C: Adjust dg-error for ILP32.

--- gcc/testsuite/g++.dg/cpp0x/constexpr-cast.C.jj      2016-08-08 
21:42:30.825683528 +0200
+++ gcc/testsuite/g++.dg/cpp0x/constexpr-cast.C 2017-06-21 12:30:19.425955047 
+0200
@@ -7,7 +7,7 @@ int i;
 // The following is accepted due to bug 49171.
 constexpr void *q = reinterpret_cast<void*>(&i);    // { dg-error "" "bug 
c++/49171" { xfail *-*-* } }
 
-constexpr void *r0 = reinterpret_cast<void*>(1);    // { dg-error "not a 
constant expression" }
+constexpr void *r0 = reinterpret_cast<void*>(1);    // { dg-error "not a 
constant expression|reinterpret_cast from integer to pointer" }
 constexpr void *r1 = reinterpret_cast<void*>(sizeof 'x');  // { dg-error 
".reinterpret_cast<void\\*>\\(1\[ul\]\*\\). is not a constant expression" }
 
 template <class T>


        Jakub

Reply via email to