Code AnalysisBeginner 60s
initializer_list lifetime pitfall
struct Bag {
std::initializer_list<int> xs;
};
Bag make() { return Bag{{1, 2, 3}}; }
int main() { Bag b = make(); for (int x : b.xs) std::cout << x; }
What is the root cause of the undefined behavior here?
Think you can answer under pressure?
Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.