Standardese quiz
876 clause-cited C++ questions built around the tempting wrong answer—covering overload resolution, object lifetime, undefined behavior, atomics, templates, and C++26. Every verdict explains the abstract-machine rule and links directly to the ISO draft.
Cleared 0 of 876 standard traps0 attempted (0% score)
translation-units-and-linkage-q1.quiz
How does the compiler handle a #include "config.hpp" directive before phase 7 semantic analysis begins?
translation-units-and-linkage-q2.quiz
You need a helper struct Buffer defined in two different .cpp files with different layouts and no ODR collision. Which declaration gives Buffer internal linkage?
translation-units-and-linkage-q3.quiz
Why does putting this header snippet into two translation units violate the One Definition Rule?
snippet.cpp
const int kRetries = 4;
inline const int* retry_ptr() {
return &kRetries;
}translation-units-and-linkage-q4.quiz
What happens if a header included by two .cpp files contains `extern "C" { int shared_status; }`?
translation-units-and-linkage-q5.quiz
What are the scope, storage duration, and linkage of `hits` in this inline function?
snippet.cpp
inline int bump() {
static int hits = 0;
return ++hits;
}translation-units-and-linkage-q6.quiz
Under [basic.link], which namespace-scope declaration still has external linkage in C++17 and later?
one-definition-rule-header-function.quiz
This header is included by `a.cpp` and `b.cpp`, which are linked into one program. What does the standard say?
snippet.cpp
// util.h
int twice(int x) { return 2 * x; }one-definition-rule-odr-use-min.quiz
There is no definition of `S::n` outside the class. Which function odr-uses `S::n`, so that the program needs such a definition?
snippet.cpp
#include <algorithm>
struct S { static const int n = 5; };
int a() { return S::n; }
int b() { return S::n + 1; }
int c(int k) { return std::max(k, S::n); }
int d() { int arr[S::n]{}; return arr[0]; }one-definition-rule-what-may-repeat.quiz
Which of these may be defined, identically, in several translation units of one program?
one-definition-rule-different-inline-bodies.quiz
`a.cpp` contains `inline int version() { return 1; }` and `b.cpp` contains `inline int version() { return 2; }`. Both call `version()`, and both are linked into one program. What does the standard say?
one-definition-rule-constexpr-ref.quiz
This header is included by several translation units of one program. What is its status?
snippet.cpp
// limits.h
constexpr int max_depth = 32;
inline const int& depth_ref() { return max_depth; }one-definition-rule-inline-static-local.quiz
The header defines `inline int next() { static int n = 0; return ++n; }`. `a.cpp` includes it and defines `int fa() { return next(); }`. `main.cpp` also includes it. What does this `main.cpp` print?
snippet.cpp
#include <cstdio>
inline int next() { static int n = 0; return ++n; }
int fa();
int main() {
int x = fa();
int y = next();
std::printf("%d %d\n", x, y);
}one-definition-rule-lambda-odr-use.quiz
Which lambda makes `demo` ill-formed?
snippet.cpp
void demo() {
const int n = 3;
auto a = [] { return n; };
auto b = [] { return n * 2; };
auto c = [] { return sizeof(n); };
auto d = [] { return &n; };
}one-definition-rule-inline-everywhere.quiz
`a.cpp` defines `inline int helper() { return 42; }`. `b.cpp` declares `int helper();` without `inline` and calls it. What does the C++23 standard say?
name-lookup-and-adl-q1.quiz
What is the role of `using Base::log;` inside a derived class that defines `void log(int)` when `Base` defines `void log(double)`?
name-lookup-and-adl-q2.quiz
Which call disables Argument-Dependent Lookup when invoking a free function `process` on an object `v` of type `geom::Vec`?
name-lookup-and-adl-q3.quiz
What happens when calling `w.emit(42)` on this class?
snippet.cpp
struct Writer {
void emit(double) {}
private:
void emit(int) {}
};
void test(Writer& w) { w.emit(42); }name-lookup-and-adl-q4.quiz
Why does `return value;` inside `Derived<T>::get()` fail to compile when `Base<T>` defines `int value = 1;`?
snippet.cpp
template<class T> struct Base { int value = 1; };
template<class T> struct Derived : Base<T> {
int get() const { return value; }
};name-lookup-and-adl-q5.quiz
Under [basic.lookup.argdep], which declaration found by ordinary unqualified lookup prevents ADL from running for `swap(a, b)`?
snippet.cpp
namespace ns { struct Item {}; void swap(Item&, Item&); }
void run(ns::Item& a, ns::Item& b) {
void swap(int&, int&);
swap(a, b);
}name-lookup-and-adl-q6.quiz