Home > Backend Development > C++ > body text

Is the evaluation order of operands in `a b` guaranteed in C ?

Linda Hamilton
Release: 2024-10-31 23:05:29
Original
743 people have browsed it

Is the evaluation order of operands in `a   b` guaranteed in C  ?

Evaluation Order of Operands in C

When evaluating an expression involving multiple operands, it's essential to understand the order in which they are processed. In the specific case of a b, is a guaranteed to be evaluated before b, or is the order indeterminate?

According to the C Standard:

For User-Defined Types:

  • a b is treated as a function call, and the order of argument evaluation is unspecified.

For Regular Operators:

  • The order of evaluation of operands and subexpressions is generally unspecified. However, in C 11, the wording has changed to "unsequenced," essentially meaning the same thing.

Therefore, in both C and C, the evaluation order of a and b in the expression a b is not determined by the language specification. It may vary depending on factors such as compiler optimizations and hardware architecture.

The above is the detailed content of Is the evaluation order of operands in `a b` guaranteed in C ?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!