Skip to content
Discussion options

You must be logged in to vote

This is expected behavior, not a compiler bug — the confusion comes from mixing up two different guarantees.

The left-to-right evaluation guarantee you're thinking of applies to braced-init-list element evaluation order (each element of { ... } is sequenced before the next). That part is correctly honored by all three compilers: element 0 (args[0] + step()) is fully evaluated before element 1, which is fully evaluated before element 2.

But that guarantee only sequences the elements relative to each other — it says nothing about the order of evaluation of the two operands within a single element, i.e. args + step(). The order of evaluating the left operand (args) vs. the right operand (step()

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@studioframes
Comment options

Answer selected by studioframes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Ask and answer questions about GitHub features and usage Programming Help Discussions around programming languages, open source and software development source:ui Discussions created via Community GitHub templates
2 participants