From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A0597384F000; Fri, 18 Jun 2021 16:44:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A0597384F000 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/101123] [11/12 Regression] Invalid code for MAX0 with -fdefault-integer-8 Date: Fri, 18 Jun 2021 16:44:15 +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: 12.0 X-Bugzilla-Keywords: ice-on-valid-code, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: WAITING X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.2 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, 18 Jun 2021 16:44:15 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101123 --- Comment #5 from Jakub Jelinek --- This is clearly a FE bug: gfc_conv_intrinsic_minmax does: if (TREE_CODE (type) =3D=3D INTEGER_TYPE) se->expr =3D fold_build1_loc (input_location, FIX_TRUNC_EXPR, type, mva= r); else se->expr =3D convert (type, mvar); and as type (in this kase integer(kind=3D8)) is INTEGER_TYPE, it creates a FIX_TRUNC_EXPR. But that is only valid if mvar has floating point type, wh= ich is not the case here. Why don't you do se->expr =3D convert (type, mvar); unconditionally? That = should create FIX_TRUNC_EXPR for the FLOAT_TYPE -> INTEGER_TYPE conversion as well, but will handle correctly even INTEGER_TYPE -> INTEGER_TYPE conversions etc= .?=