From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0676A393741B; Tue, 17 Mar 2020 18:34:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0676A393741B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1584470049; bh=eTBvBdwNF0eZNzvzgQER0vuKtRsY86oDbzQYVJ6tSxc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZpBh9tcfmV7uTr6XVEFgtRR9GB+Ka10ou8AoA9kmd58fhKOyYZdRyM+Eqpd9cuceQ 6d0ULvp/oR8+LS+lqvX1t6xBBNxDjhqwcDIiUAA2a3w1izwiuPwymkFuGrzXbsF/Eb yLiriwt7ln/uBf2XpwuukDYcb196s+vINqAR7LTs= From: "ppalka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/92010] [8/9/10 Regression] gcc internal error since 8x on warning write-strings Date: Tue, 17 Mar 2020 18:34:08 +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: 9.2.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: ppalka at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: ppalka at gcc dot gnu.org X-Bugzilla-Target-Milestone: 8.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 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: Tue, 17 Mar 2020 18:34:09 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D92010 --- Comment #7 from Patrick Palka --- (In reply to Patrick Palka from comment #6) > (In reply to Patrick Palka from comment #5) > > The ICE seems to be revealing a latent issue: In the following example > > (which GCC accepts), according to the static_assert labelled (1), the t= ype > > of t is const int*, but according to the static_assert labelled (2), the > > type of t is int *const. > >=20 > >=20 > >=20 > > template > > void foo(const T t) > > { > > static_assert(__is_same(decltype(t), const int*)); // (1) > > } > >=20 > > static_assert(__is_same(decltype(foo), void(int *))); // (2) > >=20 > > int > > main() > > { > > foo(nullptr); > > } >=20 > So the question becomes, what should the type of t be here? According to > https://eel.is/c++draft/temp#deduct-3: >=20 > "A top-level qualifier in a function parameter declaration does not affect > the function type but still affects the type of the function parameter > variable within the function." >=20 > The above suggests that the type of foo should be the same regardl= ess > of where the parameter t is const-qualified. Going by this then, it appe= ars > that the static_assert (2) is right and (1) is wrong. Can anyone confirm? >=20 > (On the other hand, Clang thinks (1) is right and (2) is wrong.) So I think the quoted wording from [temp.deduct]/3 applies to function parameter types _after_ substitution. So this doesn't definitively tell us anything about the type of t. I think the answer lies in [basic.type.qualifier]/3, which says: "Cv-qualifiers applied to an array type attach to the underlying element ty= pe, so the notation =E2=80=9Ccv T=E2=80=9D, where T is an array type, refers to= an array whose elements are so-qualified ([dcl.array]" So the type const T after substituting T=3Dint[] is precisely const int[], = which as a parameter type then decays to const int* according to [dcl.fct]/5. So= it seems that the static_assert (1) is right, and (2) is wrong.=