Skip to content

[intro.execution] p11 Do evaluations of argument expressions occur within the function invocation? #955

Description

@xmh0511

Full name of submitter (unless configured in github; will be published with the issue): Jim X

Consider this example:

int f(int i){
    return i;
}
int main(){
    int i = 0;
    auto r = f(i++) + i;
}

GCC reports no warning about unsequenced while Clang does. [intro.execution] p11 says:

When invoking a function f (whether or not the function is inline), every argument expression and the postfix expression designating f are sequenced before every precondition assertion of the function call ([expr.call]), which in turn are sequenced before every expression or statement in the body of f, which in turn are sequenced before every postcondition assertion of the function call.

This wording sounds like the evaluations of argument expressions occur within the function invocation, so their evaluation cannot interleave with those evaluations that don't occur within the function invocation. IIUC, the evaluation of i++ should be indeterminately sequenced with the value computation of the right operand i. However, there is an implementation divergence here.

Suggested Resolution:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions