From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9BF733858431; Thu, 25 Apr 2024 22:37:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9BF733858431 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714084638; bh=WUQwwIUM5SRLubmF6rwgn+/Ke009k391v3FzrmcJQFA=; h=From:To:Subject:Date:From; b=Qwyrl2XYNmMXhiOL+JE79/8hid5sQRQ4R1dR7LijqWRvMP/YfZun+k35Yckk7+NW9 5tX2FUaj9LXQUpuVeyZjczQpr28lrtpDi14wLbWiZvzMF4p0r7w0viGHh0QaFJWLdW yCW5zMbkWgw3/7sgLxNTd2w+P0BMhPTksyWvvhZg= From: "luigighiron at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/114857] New: Pointer attributes and qualifiers are parsed in wrong order Date: Thu, 25 Apr 2024 22:37:18 +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: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: luigighiron 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=3D114857 Bug ID: 114857 Summary: Pointer attributes and qualifiers are parsed in wrong order Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: luigighiron at gmail dot com Target Milestone: --- GCC accepts the following declaration: int*const[[]]p=3D0; And rejects the following declaration: int*[[]]const p=3D0; It seems that GCC expects the attributes of a pointer declarator to come af= ter the qualifiers. The standard specifies in the grammar that the attributes should come before qualifiers and not after: > ptr-operator: > * attribute-specifier-seq opt cv-qualifier-seq opt > & attribute-specifier-seq opt > && attribute-specifier-seq opt > nested-name-specifier * attribute-specifier-seq opt cv-qualifier-seq opt Section 9.3.1 "General" [dcl.decl.general] Paragraph 5 ISO/IEC 14882:2020 The first declaration should be rejected and the second declaration should = be accepted. Clang and MSVC get this correct (though not EDG I think so Visual Studio will show errors in the correct declarations and not in the incorrect declarations), and GCC gets this correct with pointer to members but not wi= th normal pointers.=