Quiz de C: Undefined Behavior

Undefined behaviour is the part of C where the standard makes no promises, and modern optimisers take full advantage of that. This hard quiz asks you to recognise common cases, tell them apart from implementation-defined behaviour and explain why "it works on my machine" proves nothing.

Difícil 10 perguntas ~8 minutos Aprovação com 80% C17

Escolha um modo

Jogando como visitante: entre para guardar seu XP e sua sequência.

Pergunta de exemplo

Pergunta 1 de 10

What does i = i++ + 1; do?

Mostrar a resposta

B. It is undefined behaviour: i is modified twice without a sequence point between the changes Both the ++ and the assignment write i, and C does not order those two writes. That is undefined behaviour, so different compilers and optimisation levels may give different results.

O que este quiz cobre

  • What "undefined" means compared with implementation-defined
  • Signed overflow, oversized shifts and unsequenced modifications
  • Out-of-bounds access and strict aliasing
  • How optimisers use UB to delete code
  • Finding UB with sanitizers

Perguntas frequentes

Preciso de uma conta?

Não. Qualquer pessoa pode jogar. Entre para guardar seu XP, sequência, badges e histórico.

Posso refazer?

Pode. Sua melhor nota fica salva, e as perguntas e respostas são embaralhadas a cada vez.