From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 D9CE73858D39 for ; Tue, 9 Nov 2021 13:55:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D9CE73858D39 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-226-rF_1dT_ENaCcKVMdmo4cUA-1; Tue, 09 Nov 2021 08:55:42 -0500 X-MC-Unique: rF_1dT_ENaCcKVMdmo4cUA-1 Received: by mail-qk1-f200.google.com with SMTP id t15-20020a05620a450f00b0046325fa7b93so13145826qkp.1 for ; Tue, 09 Nov 2021 05:55:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=mBtfZ8Kp1s6IYn9HTg6OuJc11RJVGEk3x0IsS9RRmpQ=; b=eCO7mepN4QpXWV0EJvbXwPF86OxRnuOmDGuU5i4t9Kf7Ex8Z5U7so1hSocA8QPFs1w Nup6scFUbY8euREzXyN4i5mkr659EcVlPFLmPR9jhILUAAkNcXLaSIkvsSnIpHuCps2V uTGSmwtY8gxSBf549rVnaGF32mILH5FsWXpPv6oZKPopX24SAvo0LHzydPLU0ODffg/G TL378h74zZgjAKFX+8K7ren6TvXWT9K4dJTcaPXnMPIParMG5YPUY5Keez7lDSCjGFWa Wlg25NAPuAGo670Q2oc/xOHjonsq2rC5DjEcRvhPkUftIvMq9H1NJBeL1EqaJjjno4DZ xOdQ== X-Gm-Message-State: AOAM533mlvWuK7D24W8dw3oU+Npdh2KQo8pMMLJ9KR4E1nDBS8rCXaP5 BcY1Gz6EMPmUKXuXGlJYzbF189cIfZ4qCEbCqN5xQ1YwjdpK0iW0cAlUMcsozPnLYzYpXyTAf+W W3MLDAoQcm7LxQ1BuoQ== X-Received: by 2002:ac8:5e4f:: with SMTP id i15mr2567100qtx.408.1636466141798; Tue, 09 Nov 2021 05:55:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJziKswXsji/cXxeAph5YIho7HN8Gz324/9RSbwGy3eT24DE1wnYU2+AvGzBPG4sjD17mBttaQ== X-Received: by 2002:ac8:5e4f:: with SMTP id i15mr2567071qtx.408.1636466141522; Tue, 09 Nov 2021 05:55:41 -0800 (PST) Received: from [192.168.1.149] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id j24sm11256310qkg.133.2021.11.09.05.55.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Nov 2021 05:55:40 -0800 (PST) Message-ID: <0bdf2dd2-62c4-3830-fe0f-600ffc718a0e@redhat.com> Date: Tue, 9 Nov 2021 08:55:40 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: [PATCH] c++: Fix ICE on complex constant with -frounding-math [PR103114] To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org References: <20211109093843.GM2710@tucnak> From: Jason Merrill In-Reply-To: <20211109093843.GM2710@tucnak> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Nov 2021 13:55:45 -0000 On 11/9/21 04:38, Jakub Jelinek wrote: > Hi! > > The FE uses build_complex which assumes that fold_convert will fold > value to a constant. With -frounding-math that isn't guaranteed though. > So, the patch instead fold_build2s COMPLEX_EXPR, which will result > in build_complex if both arguments are constants, and otherwise > will build COMPLEX_EXPR. > build_zero_cst is an optimization for fold_convert (type, integer_zero_node). > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? OK. > 2021-11-09 Jakub Jelinek > > PR c++/103114 > * parser.c (cp_parser_userdef_numeric_literal): Use fold_build2 > with COMPLEX_EXPR arg instead of build_complex, use build_zero_cst > instead of fold_convert from integer_zero_node. > > * g++.dg/ext/complex10.C: New test. > > --- gcc/cp/parser.c.jj 2021-10-28 20:07:48.571193189 +0200 > +++ gcc/cp/parser.c 2021-11-08 23:10:14.623106858 +0100 > @@ -4804,9 +4804,8 @@ cp_parser_userdef_numeric_literal (cp_pa > else /* if (id_equal (suffix_id, "il")) */ > type = long_double_type_node; > > - value = build_complex (build_complex_type (type), > - fold_convert (type, integer_zero_node), > - fold_convert (type, value)); > + value = fold_build2 (COMPLEX_EXPR, build_complex_type (type), > + build_zero_cst (type), fold_convert (type, value)); > } > > if (cp_parser_uncommitted_to_tentative_parse_p (parser)) > --- gcc/testsuite/g++.dg/ext/complex10.C.jj 2021-11-08 23:09:58.826331001 +0100 > +++ gcc/testsuite/g++.dg/ext/complex10.C 2021-11-08 23:09:21.847855693 +0100 > @@ -0,0 +1,5 @@ > +// PR c++/103114 > +// { dg-do compile } > +// { dg-options "-frounding-math" } > + > +_Complex double d = 10.1i; > > Jakub >