https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111538
Bug ID: 111538 Summary: Unhelpful message when returning initializer list when deducing the return type Product: gcc Version: 13.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: barry.revzin at gmail dot com Target Milestone: --- Consider: auto f(bool c) { if (c) { return 2; } else { return {}; } } This code is ill-formed, but the error gcc 13 gives is: <source>:5:17: error: returning initializer list 5 | return {}; | ^ But returning an initializer list is fine... sometimes. It's just not fine here, specifically. So would be nice if the error reflected that. Maybe something to the effect of: "error: returning an initializer list from a function with deduced return type is not allowed"