Espaços nominais
Variantes
Acções

Order of evaluation

Da cppreference.com
< c‎ | language

 
 
Linguagem C
Tópicos gerais
Original:
General topics
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Preprocessor
Comentários
Palavras-chave
Tabela ASCII
Seqüências de escape
História da C
Controle de fluxo
Original:
Flow control
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Declarações execução condicional
Original:
Conditional execution statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Instruções de iteração
Original:
Iteration statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Ir declarações
Original:
Jump statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Funções
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
declaração da função
linha especificador
Tipos
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Especificadores
Original:
Specifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
cv especificadores
armazenamento de classe especificadores
alignas especificador (C99)
Literais
Original:
Literals
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Expressões
Original:
Expressions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ordem de avaliação
operadores alternativos
operadores
precedência do operador
Utilitários
Original:
Utilities
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
typedef declaration
atributos (C99)
lança
Diversos
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Assembly embutido
 
Ordem de avaliação dos operandos de qualquer operadora C, incluindo a ordem de avaliação de argumentos de função em uma expressão chamada de função, e a ordem de avaliação das subexpressões dentro de qualquer expressão não é especificado (exceto onde indicado abaixo). O compilador irá avaliá-los em qualquer ordem, e pode escolher outra ordem, quando a mesma expressão é avaliada novamente.
Original:
Order of evaluation of the operands of any C operator, including the order of evaluation of function arguments in a function-call expression, and the order of evaluation of the subexpressions within any expression is unspecified (except where noted below). The compiler will evaluate them in any order, and may choose another order when the same expression is evaluated again.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Não existe o conceito de esquerda para a direita ou da direita para a esquerda de avaliação em C, o que não deve ser confundido com a esquerda para a direita e da direita para a esquerda associatividade de operadores: o a + b + c expressão é analisada como (a + b) + c devido a da esquerda para a direita associatividade de operador +, mas a c subexpressão pode ser avaliada primeiro (ou o último, ou ao mesmo tempo, como a ou b) em tempo de execução.
Original:
There is no concept of left-to-right or right-to-left evaluation in C, which is not to be confused with left-to-right and right-to-left associativity of operators: the expression a + b + c is parsed as (a + b) + c due to left-to-right associativity of operator+, but the subexpression c may be evaluated first (or last, or at the same time as a or b) at run time.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Índice

[editar] Definições

[editar] Avaliações

Existem dois tipos de avaliações realizadas pelo compilador para cada expressão ou subexpressão (ambos os quais são opcionais):
Original:
There are two kinds of evaluations performed by the compiler for each expression or subexpression (both of which are optional):
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • ' Computação de valor: o cálculo do valor que é retornado pela expressão. Isto pode envolver a determinação da identidade do objecto (lvalue avaliação) ou a leitura do valor previamente atribuído a um objecto (avaliação rvalue)
    Original:
    value computation: calculation of the value that is returned by the expression. This may involve determination of the identity of the object (lvalue evaluation) or reading the value previously assigned to an object (rvalue evaluation)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • ' Efeito colateral: o acesso (leitura ou gravação) para um objeto designado por um glvalue volátil, modificação (escrita) a um objeto, modificar um arquivo, modificando o ambiente de ponto flutuante (se for suportado), ou chamar uma função que faz qualquer dessas operações.
    Original:
    side effect: access (read or write) to an object designated by a volatile glvalue, modification (writing) to an object, modifying a file, modifying the floating-point environment (if supported), or calling a function that does any of those operations.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
Se nenhuns efeitos secundários são produzidas por uma expressão e o compilador pode determinar que o valor não é utilizada, a expressão não é avaliada.
Original:
If no side effects are produced by an expression and the compiler can determine that the value is not used, the expression is not evaluated.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Ordenação

"Seqüenciado-antes" é uma assimétrica, transitiva, a relação de pares entre as avaliações dentro da mesma linha (que pode estender-se entre segmentos se tipos atômicos e barreiras de memória estão envolvidos).
Original:
"sequenced-before" is an asymmetric, transitive, pair-wise relationship between evaluations within the same thread (it may extend across threads if atomic types and memory barriers are involved).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • Se um ponto de sequência está presente entre a E1 e E2 subexpressions, então ambos cálculo de valor e os efeitos colaterais de E1 são sequenciados antes de cada cálculo de valor e efeito colateral de E2
    Original:
    If a sequence point is present between the subexpressions E1 and E2, then both value computation and side effects of E1 are sequenced before every value computation and side effect of E2
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Se a avaliação é seqüenciado A avaliação antes de B, então a avaliação de A será concluída antes da avaliação B começa. (desde C11)
    Original:
    If evaluation A is sequenced before evaluation B, then evaluation of A will be complete before evaluation of B begins. (desde C11)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Se A não é sequenciado antes de B e B é sequenciado antes de A, seguida de avaliação B estará completa antes da avaliação A começa. (desde C11)
    Original:
    If A is not sequenced before B and B is sequenced before A, then evaluation of B will be complete before evaluation of A begins. (desde C11)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Se A não é seqüenciado antes de B e B não é seqüenciado antes de A, então existem duas possibilidades: (desde C11)
    Original:
    If A is not sequenced before B and B is not sequenced before A, then two possibilities exist: (desde C11)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • * Avaliações de A e B são não seqüenciada: eles podem ser realizados em qualquer ordem e podem sobrepor (dentro de um único segmento de execução, o compilador pode intercalam as instruções da CPU que compreendem A e B)
    Original:
    * evaluations of A and B are unsequenced: they may be performed in any order and may overlap (within a single thread of execution, the compiler may interleave the CPU instructions that comprise A and B)
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • * Avaliações de A e B são indeterminably-sequenciados: podem ser executadas em qualquer ordem, mas não podem sobrepor-se: ou A estará completa antes de B, ou B estará completa antes A. A ordem pode ser o oposto da próxima vez que a mesma expressão é avaliada.
    Original:
    * evaluations of A and B are indeterminably-sequenced: they may be performed in any order but may not overlap: either A will be complete before B, or B will be complete before A. The order may be the opposite the next time the same expression is evaluated.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

[editar] Regras

1)
Há um ponto de seqüência após a avaliação de todos os argumentos da função e do designador de função, e antes da chamada de função real.
Original:
There is a sequence point after the evaluation of all function arguments and of the function designator, and before the actual function call.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
Os cálculos de valor (mas não os efeitos secundários) de operandos a qualquer operador são sequenciados antes do cálculo do valor do resultado do operador (mas não os seus efeitos secundários). (desde C11)
Original:
The value computations (but not the side-effects) of the operands to any operator are sequenced before the value computation of the result of the operator (but not its side-effects). (desde C11)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3)
Há um ponto de seqüência após avaliação da primeira (esquerda) e operando antes da avaliação da segunda (direita) operando dos seguintes operadores binários: && (E lógico), || (OR lógico), e , (vírgula).
Original:
There is a sequence point after evaluation of the first (left) operand and before evaluation of the second (right) operand of the following binary operators: && (logical AND), || (logical OR), and , (comma).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
4)
Há um ponto de seqüência após avaliação da primeira (esquerda) e operando antes da avaliação do operando segundo ou terceiro (o que é avaliado) do ?: operador condicional
Original:
There is a sequence point after evaluation of the first (left) operand and before evaluation of the second or third operand (whichever is evaluated) of the conditional operator ?:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
5)
O efeito colateral (modificação do argumento à esquerda) do operador de atribuição direta e de todos os operadores de atribuição compostos é seqüenciado após o cálculo de valor (mas não os efeitos colaterais) de argumentos direito e esquerdo. (desde C11)
Original:
The side effect (modification of the left argument) of the direct assignment operator and of all compound assignment operators is sequenced after the value computation (but not the side effects) of both left and right arguments. (desde C11)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
6)
O cálculo do valor dos operadores e postincrement postdecrement é sequenciado antes de seu efeito colateral. (desde C11)
Original:
The value computation of the postincrement and postdecrement operators is sequenced before its side-effect. (desde C11)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
7)
Há um ponto de sequência no final de um declarator completo. (desde C99)
Original:
There is a sequence point at the end of a full declarator. (desde C99)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
8)
Há um ponto de seqüência após a avaliação de uma expressão completa (uma expressão que não é uma subexpressão: normalmente algo que termina com um ponto e vírgula ou uma declaração de controle if / switch / / while fazer) e antes da próxima expressão completa.
Original:
There is a sequence point after the evaluation of a full expression (an expression that is not a subexpression: typically something that ends with a semicolon or a controlling statement of if/switch/while/do) and before the next full expression.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
9)
Há um ponto imediatamente antes da sequência de retorno de uma função biblioteca. (desde C99)
Original:
There is a sequence point immediately before the return of a library function. (desde C99)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
10)
Há um ponto de sequência após a ação associada a cada especificador de conversão em formato de I / O. (desde C99)
Original:
There is a sequence point after the action associated with each conversion specifier in formatted I/O. (desde C99)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
11)
Há pontos de sequência antes e imediatamente após cada chamada para uma função de comparação feitas por as funções de biblioteca qsort e bsearch, bem como entre as chamadas para a função de comparação e o movimento dos objectos associados feitas por qsort (desde C99)
Original:
There are sequence points before and immediately after each call to a comparison function made by the library functions qsort and bsearch, as well as between any call to the comparison function and the movement of the associated objects made by qsort (desde C99)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
12)
Uma chamada de função que não é seqüenciado antes ou depois sequenciaram outra chamada de função é indeterminadamente sequenciado (instruções da CPU que constituem chamadas de funções diferentes não podem ser intercalados, mesmo que as funções são inlined) (desde C11)
Original:
A function call that is not sequenced before or sequenced after another function call is indeterminately sequenced (CPU instructions that constitute different function calls cannot be interleaved, even if the functions are inlined) (desde C11)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
13)
Em expressões lista de inicialização, todas as avaliações são indeterminadamente seqüenciado (desde C11)
Original:
In initialization list expressions, all evaluations are indeterminately sequenced (desde C11)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
14)
No que diz respeito a uma chamada de função indeterminadamente-sequenciado, a operação de operadores compostos de atribuição e tanto de prefixo e de sufixo formas de incremento e decremento operadores são avaliações individuais. (desde C11)
Original:
With respect to an indeterminately-sequenced function call, the operation of compound assignment operators, and both prefix and postfix forms of increment and decrement operators are single evaluations. (desde C11)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Comportamento indefinido

1)
Se um efeito secundário de um objecto não seqüenciada escalar é relativa a um outro efeito secundário sobre o objecto escalar mesmo, o comportamento é indefinido.
Original:
If a side effect on a scalar object is unsequenced relative to another side effect on the same scalar object, the behavior is undefined.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

i = ++i + i++; // undefined behavior
i = i++ + 1; // undefined behavior
f(++i, ++i); // undefined behavior
f(i = -1, i = -1); // undefined behavior

2)
Se um efeito secundário de um objecto não seqüenciada escalar é relativa a um cálculo de valor com o valor do objecto escalar mesmo, o comportamento é indefinido.
Original:
If a side effect on a scalar object is unsequenced relative to a value computation using the value of the same scalar object, the behavior is undefined.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

f(i, i++); // undefined behavior
a[i] = i++; // undefined bevahior

3)
As regras acima se aplicam, desde que pelo menos um permitida ordenação de subexpressões permite tal não seqüenciada efeito colateral.
Original:
The above rules apply as long as at least one allowable ordering of subexpressions permits such an unsequenced side-effect.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Veja também

Precedência do operador que define como expressões são criadas a partir de sua representação de código fonte.
Original:
Precedência do operador which defines how expressions are built from their source code representation.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.