From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 465423858D37; Fri, 22 Sep 2023 14:17:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 465423858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1695392227; bh=sycZAkyQH5HROD/GZWJzudCA1M7ngZAkQ9J+q3WHCCc=; h=From:To:Subject:Date:From; b=k2Y1oaM3zBarGURpkyo7SYYvsLlBvuoC8WEeJfHi0li4jt9WukoF89MMY42Vby/OX G/5Rf95PlrVMVenxhw4PkS0NEKkhU4HBkuvoartWA/KyduDmkxlEW3+yW4fk/CJQy7 iXwh2l0KlDb8981c/X5KC1DsPT+lU4R4HGXVgJpg= From: "barry.revzin at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/111538] New: Unhelpful message when returning initializer list when deducing the return type Date: Fri, 22 Sep 2023 14:17:06 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: barry.revzin at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111538 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: :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 t= ype is not allowed"=