From patchwork Sun Mar 19 08:32:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 71722 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp637091wrt; Sun, 19 Mar 2023 01:33:33 -0700 (PDT) X-Google-Smtp-Source: AK7set+GRBZKF2S/4iQA7DJQedIaKtJtUmTVxXtJ3Xfcnymn0sslsAbDcq9vsGnS0uPVF97mjZI+ X-Received: by 2002:a05:6402:5158:b0:4fa:ecdc:e44b with SMTP id n24-20020a056402515800b004faecdce44bmr8122264edd.24.1679214813538; Sun, 19 Mar 2023 01:33:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679214813; cv=none; d=google.com; s=arc-20160816; b=lA9R2MsHxk0xVvczmdL6P0Zt/72eGLPclpfIIX5gyyEezAjp8w1kwfbVW3rW1+lV3C ifWGfVCl/iaa+pzUteBA8Kfo3jPe3+gKhIasPQJsu+QIpFnbSJxDdcsaT8CzxIHZCbfT HyIpQszBjqK1txqkOMjGtHNudrlokQ2bmgwCpPhRzZABGWVVombIDIYVD3Lqz0cyBl/E 3f/wwkbiJGWmhRdF99n65Btp1zMTV4nbU64E92i1w/pBGXg6RT7k+gT81C5o1NxBl2XT KAq+rRQXRRmDvYdUWIineyBhUI19Ha9II8wjidLcBCgYxdsTULLxETCOiY8TLx5o22vy MZZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :content-language:user-agent:mime-version:date:message-id :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=v7uVeA6PVyGZjnSkaMX1exl3IFaimgc+yr6v1pL02E4=; b=rkzWG/KLJEgrvheELxBDDMaCKBuebW3lGscAyuZXqkuSsqjjp5mmG/K1P4S648S/52 7EZvQni3JsELFofLPjKRfSf/4/mzN2qSnkEzaoqgJcWG/zqWgZbGjoCM6hhywr/2dK7R iDloOTvkaJ5slQyqnOmpeJF7940LF9ZlCzAwLJYFWFG74/viNjHOl+wwBu5b/5IC4Lsc vYeOGGlCzv1XE6pjh6qZLGWgn1Cko8KvX2xblWPj/nVWSks8rTpnbT39B+NtU3YMAl8C 0jdmV7SCBH1+tQSIERjj6PL36cY9lL4/tleMaD6CDFKqqr0++mt2/FJtUVdaRPMaMFOu W09Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=v9ZQTNaU; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id n19-20020a056402515300b004aab36d2eb8si6911222edd.62.2023.03.19.01.33.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 01:33:33 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=v9ZQTNaU; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5942A3858C54 for ; Sun, 19 Mar 2023 08:33:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5942A3858C54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679214812; bh=v7uVeA6PVyGZjnSkaMX1exl3IFaimgc+yr6v1pL02E4=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=v9ZQTNaUWB1ggEiLKGyTmS/DkU9QlzKyAZr2sHzshsF4JyyAFucep9iTfMR6bhR4B T+38kcPzMj7gOyHlo7AAtn2wcMHYrK8yRw2688sya8wOn4HxG8ElEWv41bOw/9HHkO CjmtimLET95RKkZgoMSncFLALnsLj+q0J4tJyfPg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from cc-smtpout1.netcologne.de (cc-smtpout1.netcologne.de [89.1.8.211]) by sourceware.org (Postfix) with ESMTPS id 190813858D35; Sun, 19 Mar 2023 08:32:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 190813858D35 Received: from cc-smtpin3.netcologne.de (cc-smtpin3.netcologne.de [89.1.8.203]) by cc-smtpout1.netcologne.de (Postfix) with ESMTP id C62CC125F2; Sun, 19 Mar 2023 09:32:46 +0100 (CET) Received: from [IPV6:2001:4dd6:4ac:0:7285:c2ff:fe6c:992d] (2001-4dd6-4ac-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de [IPv6:2001:4dd6:4ac:0:7285:c2ff:fe6c:992d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by cc-smtpin3.netcologne.de (Postfix) with ESMTPSA id 92C2811DE5; Sun, 19 Mar 2023 09:32:45 +0100 (CET) Message-ID: Date: Sun, 19 Mar 2023 09:32:45 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Content-Language: en-US To: "fortran@gcc.gnu.org" , gcc-patches Subject: [patch, fortran, doc] Explicitly mention undefined overflow X-NetCologne-Spam: L X-Spamd-Bar: / X-Rspamd-Action: no action X-Rspamd-Queue-Id: 92C2811DE5 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Thomas Koenig via Gcc-patches From: Thomas Koenig Reply-To: Thomas Koenig Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760784352178432938?= X-GMAIL-MSGID: =?utf-8?q?1760784352178432938?= Here's also an update on the docs to explicitly mention behavior on overflow. Maybe this will reach another 0.05% of users... OK for trunk? Best regards Thomas gcc/fortran/ChangeLog: * gfortran.texi: Mention behavior on overflow. diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi index c483e13686d..93c66b18938 100644 --- a/gcc/fortran/gfortran.texi +++ b/gcc/fortran/gfortran.texi @@ -820,6 +820,7 @@ might in some way or another become visible to the programmer. * File operations on symbolic links:: * File format of unformatted sequential files:: * Asynchronous I/O:: +* Behavior on integer overflow::o @end menu @@ -1160,6 +1161,23 @@ sytems, such as Linux, it is necessary to specify @option{-pthread}, @c Maybe this chapter should be merged with the 'Standards' section, @c whenever that is written :-) +@node Behavior on integer overflow +@section Behavior on integer overflow +@cindex integer overflow +@cindex overflow handling + +Integer overflow is prohibited by the Fortran standard. The behavior +of gfortran on integer overflow is undefined by default. Traditional +code, like linear congruential pseudo-random number generators in old +programs that rely on specific, non-standard behavior may generate +unexpected results. The @option{-fsanitize=undefined} option can be +used to detect such code at runtime. + +It is recommended to use the intrinsic subroutine @code{RANDOM_NUMBER} +for random number generators or, if the old behavior is desired, to +use the @option{-fwrapv} option. Note that this option can impact +performance. + @node Extensions @chapter Extensions @cindex extensions