From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 47E5038449F8; Tue, 28 Nov 2023 21:29:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 47E5038449F8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701206970; bh=j05SCQv9xBF+eqefPf0j1CUdNjATqkMGsH4oUYbN1Xg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=rRAznAzCcjUtVfTOOySQxNCZDr0DBj+9Fut/yKLD22/TmZHlVyuDyCJRKFsJ2k+Hq Y6u/mJUCFp1uBE8lWqlBYpd8Fg4xsysm8oPuf0SLrFrGUUd7vZvKv0My2m2+RQ/G74 ggx7A/xExW/NpvPgJdnnnTfoklPUCOC8l2dXpP14= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/53220] [4.7/4.8 Regression] g++ mis-compiles compound literals Date: Tue, 28 Nov 2023 21:29:26 +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: 4.7.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jason at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.7.1 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=3D53220 --- Comment #23 from GCC Commits --- The trunk branch has been updated by Jason Merrill : https://gcc.gnu.org/g:305a2686c99bf9b57490419f25c79f6fb3ae0feb commit r14-5941-g305a2686c99bf9b57490419f25c79f6fb3ae0feb Author: Jason Merrill Date: Tue Nov 28 13:54:47 2023 -0500 c++: prvalue array decay [PR94264] My change for PR53220 made array to pointer decay for prvalue arrays ill-formed to catch well-defined C code that produces a dangling pointe= r in C++ due to the shorter lifetime of compound literals. This wasn't real= ly correct, but wasn't a problem until C++17 added prvalue arrays, at which point it started rejecting valid C++ code. I wanted to make sure that we still diagnose the problematic code; -Wdangling-pointer covers the array-lit.c case, but I needed to extend -Wreturn-local-addr to handle the return case. PR c++/94264 PR c++/53220 gcc/c/ChangeLog: * c-typeck.cc (array_to_pointer_conversion): Adjust -Wc++-compat diagnostic. gcc/cp/ChangeLog: * call.cc (convert_like_internal): Remove obsolete comment. * typeck.cc (decay_conversion): Allow array prvalue. (maybe_warn_about_returning_address_of_local): Check for returning pointer to temporary. gcc/testsuite/ChangeLog: * c-c++-common/array-lit.c: Adjust. * g++.dg/cpp1z/array-prvalue1.C: New test. * g++.dg/ext/complit17.C: New test.=