From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A56C3383980E; Wed, 30 Jun 2021 16:54:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A56C3383980E From: "joseph at codesourcery dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/101265] C2X [[maybe_unused]] ignored when placed after array declaration Date: Wed, 30 Jun 2021 16:54:45 +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: 11.1.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: joseph at codesourcery 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: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jun 2021 16:54:45 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101265 --- Comment #1 from joseph at codesourcery dot com --- On Tue, 29 Jun 2021, gcc at alanwu dot email via Gcc-bugs wrote: > [[maybe_unused]] int thisworks[1]; That attribute appertains to the declared entity. > int thisdoesnt[1] [[maybe_unused]]; Whereas that one appertains to the array type (that position after an=20 array declarator can also be used for e.g. a pointer to an array, an array= =20 of arrays, etc., and an attribute there appertains to the specific array=20 given by that declarator - not the declared entity as a whole). It's not clear what it would mean to declare that some particular part of=20 the type of an entity is possibly unused like that. Appropriate places in= =20 a declaration are either at the start as in the first example, or after=20 the identifier where an attribute specifier sequence appertains to the=20 declared entity. In general you need to be a lot more careful about the positioning of [[]]= =20 attributes than __attribute__.=