C++ FE relying on not folding stuff for constexprs?

Richard Biener rguenther@suse.de
Tue Nov 4 15:15:00 GMT 2014

Hi Jason,

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?


More information about the Gcc mailing list