From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 09CE93858D35; Tue, 7 Jul 2020 19:02:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 09CE93858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1594148528; bh=03GLQUQgHJ8h5+PVd7siB85eIZ0Txs55O98DspLqA7E=; h=From:To:Subject:Date:In-Reply-To:References:From; b=DlB4MlHeRn2YrLRuVn1h2F02pXht5d/wdKSxIwlI3vzU007MJktTkrCOzDd8gDDU5 6IUkb1YwYPwoo5zvDPUsPeSgDb7EK+ve++ciCQK78HoOJeJnd2vFBy1tjRnXMxVBhO f2yLxwN1Fje/Oue5BTY1AnPK5EZP8j/KzffjgIS4= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/96058] ICE in c_getstr at gcc/fold-const.c:15475 Date: Tue, 07 Jul 2020 19:02:07 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW 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: 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: Tue, 07 Jul 2020 19:02:08 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96058 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #7 from Jakub Jelinek --- (In reply to Martin Sebor from comment #6) > Am I misreading it? What's mem_size? Yes. See Martin L.'s comment, it is 10.1 release, so the line numbers are slightly different from trunk or current 10 branch. Obviously the two tree_to_uhwi calls guarded with tree_fits_uhwi_p can't be= it, but it is the third one. tree eltype =3D TREE_TYPE (TREE_TYPE (src)); /* Support only properly NUL-terminated single byte strings. */ if (tree_to_uhwi (TYPE_SIZE_UNIT (eltype)) !=3D 1) return NULL; And see #c5 on what it happens. The string_constant code added in g:14b7950f126f doesn't try to verify that chartype is some character or even integral type, nor whether it is a compl= ete type. It actually doesn't seem correct even for wchar_t/char16_t/char32_t etc., because initsize is size in bytes. Nothing tries to verify tree_fits_uhwi_p (initsize) and calls build_string_literal with the chartype and initsize converted to uhwi. Now, if initsize is HOST_WIDE_INT_M1U, it will do something different, and = even if not, build_string_literal assumes that the string has type chartype[size= ], so whenever chartype is not a byte type, but 2/4/8 byte integer, the string literal will have size that is twice/4/8 times larger type than desired.=