From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D947F385481F; Fri, 12 Mar 2021 19:20:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D947F385481F From: "sgk at troutmask dot apl.washington.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/99561] gfortran reports an error for a truncation that is permitted by the standard Date: Fri, 12 Mar 2021 19:20:48 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: sgk at troutmask dot apl.washington.edu X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID 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: 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: Fri, 12 Mar 2021 19:20:49 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99561 --- Comment #3 from Steve Kargl -= -- On Fri, Mar 12, 2021 at 06:39:49PM +0000, kargl at gcc dot gnu.org wrote: > --- Comment #1 from kargl at gcc dot gnu.org --- > (In reply to Michal Paszta from comment #0) > > In this line of code: > >=20 > > INTEGER(KIND=3D1) :: var8 =3D 257_2 > >=20 > > we try to cast an integer of kind 2 (16 bits) onto an integer of kind 1= (8 > > bits, value up to 256). This will result in a truncation of the value a= nd is > > allowed by the Fortran 2018 Standard, see Table 10.9, Fortran 2018 Stan= dard. > >=20 >=20 > The sentence preceding Table 10.9 and the table tell you=20 > what conversions are allowed and how the conversion is > done via a built-in intrinsic subprogram. >=20 > It does tell you anything about an out-of-range value. It does NOT tell > In fact, an INTEGER(KIND=3D1) entity has a range of > [-128,127], so the value of 256 is still out-of-range. Sigh, "not" was a rather important omission. :(=