Message ID | ZcCU3ijeURZ4hrFv@tucnak |
---|---|
State | Unresolved |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp727495dyb; Sun, 4 Feb 2024 23:58:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IFIoRKst2DqFt+MQhnl3fDC42jwPvV3qdNsK55DZDHPok98n8aokGy5whqYQVE0YffSc/LV X-Received: by 2002:a05:620a:cf1:b0:783:2516:58c8 with SMTP id c17-20020a05620a0cf100b00783251658c8mr12463686qkj.19.1707119882377; Sun, 04 Feb 2024 23:58:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707119882; cv=pass; d=google.com; s=arc-20160816; b=zclYjXVGBSgHSJwC+Ln6TzsoMi4OfrM0/e9/MvvBveVTqI++Gm5EeNy/BSeGo+3PJE jyMopMLQZ3kL/3EMYY0zpu1VfjZDvKv8uV0HRh+5wz6OFxbhiDgNf+f6wteW2K2Ve9rK SFl1G5AKW8T6pNjDtJ4biLv2XMGoEbZ8JT46IEuvPYCj8TOLqJX+TgMo6qHdUP/WfFlv 22REFSiM/CDk//fBIBd1aGGQjhFn3YBUMSw1BnCkUdPsIUz5uEeBGwM7nfXjkDUiaYwq ZwhHUcTy/skfTrnkBiDNxDrkCC8K6JQV9N0N2wzyIWHAM1Lpx3xZQZ8MkUuFPFunqlve DT1Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=f1Mlb2xwt2nCcjuWXvgGAuVhkBIU+E9nQrQa39yrflw=; fh=pDSw0q/z5qPz+3e9L/8Mg6wBs4GPIyBR2K+uQReTbiE=; b=HY0fHkXsuSF1+2Cg3tIFbpBAFCNnfl8LhiCi8LSYWT+U60huZuXYwTNfCbXrGDN19P z7c9PnIkwEWjNjh5+PWJP0Chn4YRKe213+JH/tgVomNflED0Npm98CaG3nKkjGTuyeBB ig1Oeh6+Gcbl7OlnBMVcZnj3btqXEscTidSG703/tGj5evdTGXpsZm6oCyLqoVhM1cVQ Emr14K4TYoTXMp8qMaCVSUvc3Hx1ZOMBW9MDKbvatnzWbdpNN+csV38G5F9CIwxyJbEE 4gp9+9DNC9+IfW0mtbrHVSa00YNPbFdaSyG23apiT07PRkG5KZXBaGUoylWxp7Dw6I0J tceQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PspgrIcL; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCVqPHFdGoulAKeXHVOUYzw61c3mvGs8Ctm7dgp5TdS0UPlYvUo5gV2g3CjWuDujAviyN9oCGiP4ggv0hPalmk1OFUtaEg== Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id c26-20020a05620a165a00b007840eac031asi8032775qko.171.2024.02.04.23.58.02 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 23:58:02 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PspgrIcL; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0213C3858439 for <ouuuleilei@gmail.com>; Mon, 5 Feb 2024 07:58:02 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id CB0453858CDB for <gcc-patches@gcc.gnu.org>; Mon, 5 Feb 2024 07:57:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CB0453858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CB0453858CDB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707119845; cv=none; b=DkWj7iOwyYnf2w27bXklBoRxg5/Kv2iXRaQTV7nQCuJPVXAAa0LR+GYcI8ZH2QlVU826NmnlLgfadh/SIvEfKWAwLdVL2+93JTLuBomO8LMfAXViBkeI67N06IgZ8kA3EMfOuZpBstxgEzER028WTbWO/gc8ku7EWS4LgBxWV0g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707119845; c=relaxed/simple; bh=3X2TNP+bMr3Jc0hpOjfP9vbi96pc/S/Ez89TbjpPRsY=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=xHDriLMaQlY2AVG6Tz+iTwGSyvzpRGUMpiuZIX1p8C3zCuxsuTIDAjQHaU72nwoTDxk364SoFNTjvGdLFtYilrxe2BtGfUTo1s/B05TfOH0SLD6uDb1r+Zf/zN7dVEO5/U/PabyP8rRWdhJpzMs18leGo/5PpmmGzsMHq1b4I84= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707119843; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=f1Mlb2xwt2nCcjuWXvgGAuVhkBIU+E9nQrQa39yrflw=; b=PspgrIcLhuQwmh/3d2ms0lFmXI9M4tQCOMXHDeEKSaJpigeVrQyvrWCfPON5EfS7Z+dC0w afpfE4q2J+lOehoCouw8eUyEBaT9RbxFzCPTENZhoqvWLsirLQVBaI1xfUlghO07s5m8kL aRps7ngUR3zuHTARWQW1vnZJqzEm+aI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-112-3-GW13K8M2-Dvn-NUyb1Sw-1; Mon, 05 Feb 2024 02:57:21 -0500 X-MC-Unique: 3-GW13K8M2-Dvn-NUyb1Sw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AF3EB185A780 for <gcc-patches@gcc.gnu.org>; Mon, 5 Feb 2024 07:57:21 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 733EB492BF0; Mon, 5 Feb 2024 07:57:21 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 4157vJ1C319254 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 5 Feb 2024 08:57:19 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 4157vIWl319253; Mon, 5 Feb 2024 08:57:18 +0100 Date: Mon, 5 Feb 2024 08:57:18 +0100 From: Jakub Jelinek <jakub@redhat.com> To: "Joseph S. Myers" <josmyers@redhat.com> Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] c: Avoid ICE with _BitInt(N) : 0 bitfield [PR113740] Message-ID: <ZcCU3ijeURZ4hrFv@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Reply-To: Jakub Jelinek <jakub@redhat.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790044937772937932 X-GMAIL-MSGID: 1790044937772937932 |
Series |
c: Avoid ICE with _BitInt(N) : 0 bitfield [PR113740]
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | warning | Git am fail log |
Commit Message
Jakub Jelinek
Feb. 5, 2024, 7:57 a.m. UTC
Hi!
finish_struct already made sure not to call build_bitint_type for
signed _BitInt(2) : 1;
or
signed _BitInt(2) : 0;
bitfields (but instead build a zero precision integral type,
we remove it later), this patch makes sure we do it also for
unsigned _BitInt(1) : 0;
because of the build_bitint_type assertion that precision is
>= (unsigned ? 1 : 2).
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2024-02-05 Jakub Jelinek <jakub@redhat.com>
PR c/113740
* c-decl.cc (finish_struct): Only use build_bitint_type if
bit-field has width larger or equal to minimum _BitInt
precision.
* gcc.dg/bitint-85.c: New test.
Jakub
Comments
On Mon, Feb 05, 2024 at 08:57:18AM +0100, Jakub Jelinek wrote: > Hi! > > finish_struct already made sure not to call build_bitint_type for > signed _BitInt(2) : 1; > or > signed _BitInt(2) : 0; > bitfields (but instead build a zero precision integral type, > we remove it later), this patch makes sure we do it also for > unsigned _BitInt(1) : 0; > because of the build_bitint_type assertion that precision is > >= (unsigned ? 1 : 2). > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? OK, thanks. > 2024-02-05 Jakub Jelinek <jakub@redhat.com> > > PR c/113740 > * c-decl.cc (finish_struct): Only use build_bitint_type if > bit-field has width larger or equal to minimum _BitInt > precision. > > * gcc.dg/bitint-85.c: New test. > > --- gcc/c/c-decl.cc.jj 2024-02-01 09:14:16.474551596 +0100 > +++ gcc/c/c-decl.cc 2024-02-03 13:03:35.272479105 +0100 > @@ -9555,7 +9555,7 @@ finish_struct (location_t loc, tree t, t > if (width != TYPE_PRECISION (type)) > { > if (TREE_CODE (type) == BITINT_TYPE > - && (width > 1 || TYPE_UNSIGNED (type))) > + && width >= (TYPE_UNSIGNED (type) ? 1 : 2)) > TREE_TYPE (field) > = build_bitint_type (width, TYPE_UNSIGNED (type)); > else > --- gcc/testsuite/gcc.dg/bitint-85.c.jj 2024-02-03 13:05:49.162639344 +0100 > +++ gcc/testsuite/gcc.dg/bitint-85.c 2024-02-03 13:05:39.489772259 +0100 > @@ -0,0 +1,5 @@ > +/* PR c/113740 */ > +/* { dg-do compile { target bitint } } */ > +/* { dg-options "-std=c23" } */ > + > +struct S { unsigned _BitInt(32) : 0; }; > > Jakub > Marek
--- gcc/c/c-decl.cc.jj 2024-02-01 09:14:16.474551596 +0100 +++ gcc/c/c-decl.cc 2024-02-03 13:03:35.272479105 +0100 @@ -9555,7 +9555,7 @@ finish_struct (location_t loc, tree t, t if (width != TYPE_PRECISION (type)) { if (TREE_CODE (type) == BITINT_TYPE - && (width > 1 || TYPE_UNSIGNED (type))) + && width >= (TYPE_UNSIGNED (type) ? 1 : 2)) TREE_TYPE (field) = build_bitint_type (width, TYPE_UNSIGNED (type)); else --- gcc/testsuite/gcc.dg/bitint-85.c.jj 2024-02-03 13:05:49.162639344 +0100 +++ gcc/testsuite/gcc.dg/bitint-85.c 2024-02-03 13:05:39.489772259 +0100 @@ -0,0 +1,5 @@ +/* PR c/113740 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=c23" } */ + +struct S { unsigned _BitInt(32) : 0; };