From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CE907382FAE9; Thu, 24 Nov 2022 18:49:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE907382FAE9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669315751; bh=bS7C4Kq2++enbp2LLzdFbhdTmMIuwbWO7oJfWWB8HLw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=xn5YjJ/mDmqMA6giDRlJ9b3GqWWY36OKG5INeD9l629/LASVTCl1RxOHPSsWmioRG qYo0XBnZvnSD62Cse6qjBi4O2iqgwOVUgqQi7TsxsxmtYrTekdB1lJ3kv0zYhe9Oit hZQZtoU/nInKxoU4yTorek9wZXf6Gpeu91MJqlyM= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107862] Returning an std::vector from a lambda fails to be constexpr, while a custom class with allocated storage works Date: Thu, 24 Nov 2022 18:49:11 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org 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: Message-ID: In-Reply-To: References: 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=3D107862 --- Comment #1 from Andrew Pinski --- I don't think this is valid code. In the function dynamic_data_to_array you have: std::array data; But test.size() is not a constexpr unless test is a constexpr. making test a constexpr does not work as it has dynamic allocation In your Test struct you have: constexpr unsigned size() const { return 1; } So it is always a constexpr ... Note clang also rejects this code for the same reason as GCC even with libc= ++.=