This is the mail archive of the
mailing list for the GCC project.
C++ FE relying on not folding stuff for constexprs?
- From: Richard Biener <rguenther at suse dot de>
- To: gcc at gcc dot gnu dot org
- Cc: jason at redhat dot com
- Date: Tue, 4 Nov 2014 16:11:03 +0100 (CET)
- Subject: C++ FE relying on not folding stuff for constexprs?
- Authentication-results: sourceware.org; auth=none
on the match-and-simplify branch I currently see
And the C++ relying on fold _not_ folding (T) (T) 4B to 4 causes
FAIL: g++.dg/cpp0x/constexpr-reinterpret1.C -std=c++11 (test for errors,
FAIL: g++.dg/cpp0x/constexpr-reinterpret1.C -std=c++1y (test for errors,
Because the C++ FE relies on fold _not_ folding (T&)(T&) 4B to 4.
Which it currently does not because if you ask fold_unary to
fold (T&) of the unfolded tree (T&) 4B then the first transform
that applies (because of accidential(?) ordering in fold_unary) is
the one stripping conversions to an equal type which just returns
the operand, (T&) 4B. On match-and-simplify no such ordering
takes place and instead we apply the transform of the most complex
pattern we can match - which is optimizing two conversions in a row.
In this case it says the middle conversion is not necessary and
converts it to (T) 4B - re-folding that which folds it to just 4
which is no longer a cast and thus we fail to warn.
I have no idea how I can keep the testcase working - to me it
seems it works by accident. So I am inclinded to XFAIL it
(it's an accept-invalid then).
Any other ideas?