From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6F5423858D34; Wed, 8 May 2024 03:19:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6F5423858D34 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1715138385; bh=kwKdq0Y7fJVQ50NKTR1r+vrd5GSXcfJcgEXcOQT2Nd0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=fGqj79FI6xcte8vFbvCBi7hPMdd4WayX1iJJ9v5uRSCKqGddStfi/fb6WIun1Wvqh NNFrZ/gGff3nx2AtmMTN6nB8eUf5s+P3Rpcd17ztVkQyQUBu8iXg3+PS5jpVXPL7FI 0HMggALUHYOoraQCk9W/F9/xF17oLtTbTSQ/RCQo= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/89224] [11/12/13/14/15 Regression] subscript of const vector has the wrong type Date: Wed, 08 May 2024 03:19:44 +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: 8.2.0 X-Bugzilla-Keywords: accepts-invalid, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: pinskia at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.5 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=3D89224 --- Comment #22 from GCC Commits --- The releases/gcc-11 branch has been updated by Andrew Pinski : https://gcc.gnu.org/g:046aeffba336295fbdaf0e1ecf64b582d08f0aa6 commit r11-11419-g046aeffba336295fbdaf0e1ecf64b582d08f0aa6 Author: Andrew Pinski Date: Tue Feb 20 13:38:28 2024 -0800 c++/c-common: Fix convert_vector_to_array_for_subscript for qualified vector types [PR89224] After r7-987-gf17a223de829cb, the access for the elements of a vector t= ype would lose the qualifiers. So if we had `constvector[0]`, the type of the element of the array wou= ld not have const on it. This was due to a missing build_qualified_type for the inner type of the vector when building the array type. We need to add back the call to build_qualified_type and now the access= has the correct qualifiers. So the overloads and even if it is a lvalue or rvalue is correctly done. Note we correctly now reject the testcase gcc.dg/pr83415.c which was incorrectly accepted after r7-987-gf17a223de829cb. Built and tested for aarch64-linux-gnu. PR c++/89224 gcc/c-family/ChangeLog: * c-common.c (convert_vector_to_array_for_subscript): Call build_qualified_type for the inner type. gcc/cp/ChangeLog: * constexpr.c (cxx_eval_array_reference): Compare main variants for the vector/array types instead of the types directly. gcc/testsuite/ChangeLog: * g++.dg/torture/vector-subaccess-1.C: New test. * gcc.dg/pr83415.c: Change warning to error. Signed-off-by: Andrew Pinski (cherry picked from commit 4421d35167b3083e0f2e4c84c91fded09a30cf22)=