public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/111538] New: Unhelpful message when returning initializer list when deducing the return type
@ 2023-09-22 14:17 barry.revzin at gmail dot com
2023-09-22 17:39 ` [Bug c++/111538] " pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: barry.revzin at gmail dot com @ 2023-09-22 14:17 UTC (permalink / raw)
To: gcc-bugs
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"
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/111538] Unhelpful message when returning initializer list when deducing the return type
2023-09-22 14:17 [Bug c++/111538] New: Unhelpful message when returning initializer list when deducing the return type barry.revzin at gmail dot com
@ 2023-09-22 17:39 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-22 17:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111538
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2023-09-22
Ever confirmed|0 |1
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.
clang gives a reasonible error message:
<source>:6:16: error: cannot deduce return type from initializer list
6 | return {};
| ^~
1 error generated.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-09-22 17:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-22 14:17 [Bug c++/111538] New: Unhelpful message when returning initializer list when deducing the return type barry.revzin at gmail dot com
2023-09-22 17:39 ` [Bug c++/111538] " pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).