From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 86A223858C50; Wed, 6 Apr 2022 22:42:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 86A223858C50 From: "ppalka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/104594] narrowing of -1 to unsigned char not detected with requires concepts Date: Wed, 06 Apr 2022 22:42:19 +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: 12.0 X-Bugzilla-Keywords: accepts-invalid X-Bugzilla-Severity: normal X-Bugzilla-Who: ppalka at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: ppalka at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: see_also cc 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, 06 Apr 2022 22:42:19 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104594 Patrick Palka changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=3D67898 CC| |jason at gcc dot gnu.org --- Comment #3 from Patrick Palka --- I wonder if this is ultimately a manifestation of PR67898. After substitut= ing into an NTTP, if the type of the NTTP or the type of its argument is still dependent then we can't yet check the implicit conversion from the argument type to the parameter type. And we don't encode this implicit conversion within the substituted argument (as e.g. an IMPLICIT_CONV_EXPR) because we'= ll check the conversion again when we call coerce_template_parms the next time around anyway. However, as PR67898 illustrates, this causes problems if a subsequent templ= ate parameter refers to this NTTP, e.g: template struct A; template using B =3D A; Here A should resolve to A but it instead resolves to A because we don't encode the implicit conversion (from int to U) within= the substituted argument for V, and hence substitution into the default argument yields decltype(W), which is just int, rather than yielding decltype(U(W)). Seems we can run into the same issue during normalization as illustrated in this current PR. The normal form for E in commment #2 is just (X !=3D 0) (= with mapping X -> X) but we really should be encoding the implicit conversions i= nto the mapping (yielding something like X -> unsigned(int(X))). So I wonder if the best way to tackle this PR is to tackle PR67898 more generally?=