Quant Developer Interview Prep roadmap

What is undefined behaviour, and why do these firms care so much?

Log in to save this

Saving keeps this in your list across devices. It's a free account — no card.

The question behind the question in every code review round. The weak answer treats UB as a crash you might get away with; the strong answer treats it as a premise the optimiser is allowed to reason from.

Exam

Answer these to pass this module.

Start here rather than at the reading. Whatever you miss tells you which part of Learn you actually need — and anything you get right is a part you can skip.

  • What is the compiler entitled to do with code that has undefined behaviour?

  • Which of these is unspecified behaviour rather than undefined behaviour?

  • A program works at -O0 and misbehaves at -O2. What should you suspect first?

Explain mode

What is undefined behaviour, and why do these firms care so much?

Give the definition, then one worked example where the optimiser removes code you wrote.

Your own words, two or three sentences, nothing looked up. The rubric unlocks once you submit.

Graded against a set rubric. Three a day on a free account. Need more? Ask on our Facebook page — it's free.

 

Log in to answer

Answering marks your choice and explains why each option is right or wrong. It's a free account — no card, and your progress is kept.

Learn

Undefined versus unspecified versus implementation-defined behaviour, why the standard leaves it open, and how optimisers use it — including how a null check can be deleted because a pointer was already dereferenced.

Ask an AI to teach you this

I'm preparing for a quant developer interview on "What is undefined behaviour, and why do these firms care so much?"
Concepts I need to own: undefined versus unspecified versus implementation-defined behaviour, why the standard leaves it open, and how optimisers use it — including how a null check can be deleted because a pointer was already dereferenced.

Run this as interview practice, not a lecture. One concept at a time.
Wait for my answer before moving on.

Per concept:
1. Teach it. Lead with the one-line core claim, then a few short
   paragraphs. Assume I write C++ but have never had this explained
   properly. No jargon without defining it.
2. "The 60-second version" — what a strong candidate would SAY out loud.
   First person, spoken register, no bullets, no headers. That's what I'm
   rehearsing.
3. Ask me one question that exposes whether I only think I understood it.

When I answer, reply in exactly this shape:

  Verdict: correct / partly correct / wrong — one line on what's wrong.
  What you missed: only if something's missing. 2-3 sentences.
  Vocabulary: only if I used a wrong or vague term. Give the right one.
  Example answer: the model spoken answer, 30 seconds max, first person.
  More info: define any term I probably don't know, one line each.
  Follow-up probe: the one question an interviewer asks someone who gave
  that model answer.

Skip any section that doesn't apply. Don't pad. If I'm wrong, say wrong —
don't soften it.

Do not write my implementation for me. If I ask, refuse and ask what I'd
try instead — I need to defend this code with the editor closed.

Do

Give the definition, then one worked example where the optimiser removes code you wrote.

Ship

One example, compiled at -O0 and -O2, where the behaviour differs and you can explain why.

Practice with AI

Use these to make the AI your examiner, not your author. If the AI wrote the code, this node doesn't count — you can't defend a design you didn't make.

  • P8 — grade my explanation against the rubric, and name what I left out
  • P3 — HFT-style code review, ends in hire/no-hire