https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71502
Bug ID: 71502 Summary: Fold expression unpacks (I < ...) the wrong way Product: gcc Version: 6.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: michele.caini at gmail dot com Target Milestone: --- Consider this proposal: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4191.html and the following fold expression: (args < ...) It should be equivalent to: ((args$0 < args$1) < ...) + args$n Consider the following code: #include<cassert> int main() { assert((0 < 42) < 3); } The assert doesn't fail as expected (note that the result is not ((0 < 42) and (42 < 3)), the expression itself is quite unusual and meaningless). On the other side, when using a fold expression: template<int... I> static constexpr bool f() { return (I < ...); } int main() { static_assert(f<0, 42, 3>(), "!"); } The assert fails at compile time. I'd expect it to compile because of what contained in the proposal. It should succeed for it is equivalent to the example above that doesn't involve fold expressions. The unpacked expression should be indeed: ((0 < 42) < 3).