ArticleslgStudy

science

Sequence point

Sequence point is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Sequence point rather than just read about it. In short: In C and C++, a sequence point defines any point in a computer program’s execution at which it is guaranteed that all side effects of previous evaluations will have been performed, and no side effects from subsequent evaluations have yet been performed. They are a core concept for determining the validity of and, if valid, the possible results of expressions.

Key takeaways

  • Sequence point belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Sequence point to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Sequence point from memory before moving on to harder problems.

Reference excerpt

In C and C++, a sequence point defines any point in a computer program’s execution at which it is guaranteed that all side effects of previous evaluations will have been performed, and no side effects from subsequent evaluations have yet been performed. They are a core concept for determining the validity of and, if valid, the possible results of expressions. Adding more sequence points is sometimes necessary to make an expression defined and to ensure a single valid order of evaluation. Documentation for C11 and C++11 stopped using the term "sequence point" and now uses alternative terms:"ISO/IEC 14882:2024"."A finer-grained alternative to sequence points (revised) (WG21/N2239 J16/07-0099)". Retrieved 2012-07-05."Order of evaluation". Retrieved 2015-10-14.

An expression's evaluation can be "sequenced before" the evaluation of another expression. (Equivalently, the other expression's evaluation can be "sequenced after" that of the first.) The expression's evaluation is "indeterminately sequenced", meaning that one is "sequenced before" the other, but which is unspecified. The expression's evaluation is "unsequenced", meaning the operations in each expression may be interleaved. The execution of unsequenced evaluations can overlap, leading to potentially catastrophic undefined behavior if they share state. This situation can arise in parallel computing, causing race conditions, but undefined behavior can also result in single-threaded situations. For example, a[i] = i++; (where a is an array and i is an integer) has undefined behavior. In earlier C standards (such as C89 and C99), sequence points were defined to occur at specific locations in code, including at the end of a full expression (such as a statement), after the evaluation of the first operand of the logical AND (&&) and logical OR (||) operators, after the first operand of the conditional (?:) operator, and at function call boundaries after all arguments have been evaluated."Sequence point rules in C and C++". Retrieved 2026-05-02.

Examples of ambiguity Consider two functions f() and g(). In C and C++, the + operator is not associated with a sequence point, and therefore in the expression f() + g() it is possible that either f() or g() will be executed first. The comma operator introduces a sequence point, and therefore in the code f(), g() the order of evaluation is defined: first f() is called, and then g() is called. Sequence points also come into play when the same variable is modified more than once within a single expression. An often-cited example is the C expression i=i++, which apparently both assigns i its previous value and increments i. The final value of i is ambiguous, because, depending on the order of expression evaluation, the increment may occur before, after, or interleaved with the assignment. The definition of a particular language might specify one of the possible behaviors or simply say the behavior is undefined. In C and C++, evaluating such an expression yields undefined behavior. Other languages, such as C#, define the precedence of the assignment operator and the increment operator in such a way that the result of the expression i=i++ is guaranteed.

Behavior

Up to C++03 In C and C++, sequence points occur in the following places. (In C++, overloaded operators act like functions, and thus operators that have been overloaded introduce sequence points in the same way as function calls.)

Between evaluation of the left and right operands of the && (logical AND), || (logical OR) (as part of short-circuit evaluation), and comma operators. For example, in the expression *p++ != 0 && *q++ != 0, all side effects of the sub-expression *p++ != 0 are completed before any attempt to access q. Between the evaluation of the first operand of the ternary conditional operator and its second or third operand. For example, in the expression a = (*p++) ? (*p++) : 0 there is a sequence point after the first *p++, meaning it has already been incremented by the time the second instance is executed. At the end of a full expression. This category includes expression statements (such as the assignment a=b;), return statements, the controlling expressions of if, switch, while, or do-while statements, and each of the three expressions in a for statement. Before a function is entered in a function call. The order in which the arguments are evaluated is not specified, but this sequence point means that all of their side effects are complete before the function is entered. In the expression f(i++) + g(j++) + h(k++), f is called with a parameter of the original value of i, but i is incremented before entering the body of f. Similarly, j and k are updated before entering g and h respectively. However, it is not specified in which order f(), g(), h() are executed, nor in which order i, j, k are incremented. If the body of f accesses the variables j and k, it might find both, neither, or just one of them to have been incremented. (The function call f(a,b,c) is not a use of the comma operator; the order of evaluation for a, b, and c is unspecified.) At a function return, after the return value is copied into the calling context. (This sequence point is only specified in the C++ standard; it is present only implicitly in C.) At the end of an initializer; for example, after the evaluation of 5 in the declaration int a = 5;. Between each declarator in each declarator sequence; for example, between the two evaluations of a++ in int x = a++, y = a++. (This is not an example of the comma operator.) After each conversion associated with an input/output format specifier. For example, in the expression printf("foo %n %d", &a, 42), there is a sequence point after the %n is evaluated and before printing 42.

C11 and C++11

C++11 brought diverse changes, including features that improve the language's performance, usability, and multithreading. Partially because of the introduction of language support for threads, C11 and C++11 introduced new terminology for evaluation order. An operation may be “sequenced before” another, the two can be “indeterminately sequenced” (one must complete before the other), or the two can be “unsequenced” (the operations in each expression may be interleaved).

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Sequence point

Start with the simplest possible case. Write down what Sequence point claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Sequence point before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Sequence point ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Sequence point

In research
Sequence point appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Sequence point in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Sequence point is common in secondary-school and first-year university syllabi. It links to neighbouring topics C++, C (programming language), Programming paradigms, so understanding it makes those chapters shorter.
In everyday life
Look for Sequence point outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Sequence point” →

How to study Sequence point in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Sequence point means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Sequence point out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Sequence point in simple terms?

In C and C++, a sequence point defines any point in a computer program’s execution at which it is guaranteed that all side effects of previous evaluations will have been performed, and no side effects from subsequent evaluations have yet been performed. They are a core concept for determining the v…

Why does Sequence point matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Sequence point?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Sequence point.

Tags

  • C++
  • C (programming language)
  • Programming paradigms

Keep exploring