https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61382

Thibaut LUTZ <thibaut.lutz at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thibaut.lutz at googlemail dot 
com

--- Comment #2 from Thibaut LUTZ <thibaut.lutz at googlemail dot com> ---
@Jonathan: you might be referring to 56774. 59716 was a similar issue.

However I think this case is definitely NOT a bug. Here is why:

- let's decompose the line:
std::tuple<ARGS...> r { get_single<ARGS>(posfoo++)... };

* std::tuple<ARGS...> r{ ... }: this is a constructor call: std::tuple(args...)
* get_single<ARGS>(posfoo++)... expands to get_single<int>(posfoo++),
get_single<float>(posfoo++), get_single<float>(posfoo++),
get_single<int>(posfoo++)

Putting the two together, with the previous line:
int posfoo = 0;
std::tuple<ARGS...> r ( get_single<int>(posfoo++),
                        get_single<float>(posfoo++),
                        get_single<float>(posfoo++),
                        get_single<int>(posfoo++));

This is the root of your problem: 
N3797 §8.3.6.9: The order of evaluation of function arguments is unspecified.

The pack expansion is working fine, but the increments to posfoo are not being
sequenced. Clang does evaluate arguments in the opposite order as GCC does,
which makes it look correct in this case, but it is still undefined behavior. 

You can re-write your get_single function to do a pack traversal instead.

Reply via email to