From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BC6D4384645B; Wed, 3 Apr 2024 20:12:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BC6D4384645B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1712175141; bh=ZsVKsP5QZqiiBq7Ru9sEgRJX5YD0Gf6c+YmWap1YF0I=; h=From:To:Subject:Date:In-Reply-To:References:From; b=WkO4ix+bnA2nCzse0Oe6Jyku9brhtulzPq9UEW938s6mqJOfDoVV6vZOKEd1rPRVq DlPBob7cXU8pTlso2l54y4GhsG8qauk7Y23eEFZ53RuOKsRe6CO0T266qYmB+NpnWK s8Nc1ZpSrV+NZeJwaeOFCiSsf8eFC7jCe4OuyHTc= From: "anlauf at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/113412] ATAN(Y,X) does not check arguments and generates wrong error message. Date: Wed, 03 Apr 2024 20:12:20 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: anlauf at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113412 --- Comment #6 from anlauf at gcc dot gnu.org --- (In reply to kargls from comment #5) > The pointers to expr->symtree is NULL. This new patch catches your examp= le. It does, but behaves weird for some other cases. Try: program main complex :: c =3D 1. complex, parameter :: z =3D 1. print *, atan(c,c) print *, atan(z,z) end This gives now: pr113412.f90:4:18: 4 | print *, atan(c,c) | 1 Error: 'c' argument of 'atan' intrinsic at (1) must be the same type and ki= nd as 'c' pr113412.f90:5:18: 5 | print *, atan(z,z) | 1 Error: 'z' argument of 'atan' intrinsic at (1) must be the same type and ki= nd as 'z' I wonder whether we can reuse existing checks for atan2 for the 2-argument version of atan. I tried the following: diff --git a/gcc/fortran/intrinsic.cc b/gcc/fortran/intrinsic.cc index c35f2bdd183..261d4229139 100644 --- a/gcc/fortran/intrinsic.cc +++ b/gcc/fortran/intrinsic.cc @@ -4370,6 +4370,11 @@ sort_actual (const char *name, gfc_actual_arglist **= ap, if (a =3D=3D NULL) goto do_sort; + if ((gfc_option.allow_std & GFC_STD_F2008) !=3D 0 + && strcmp(name, "atan") =3D=3D 0 + && !gfc_check_atan_2 (actual->expr, actual->next->expr)) + return false; + whoops: gfc_error ("Too many arguments in call to %qs at %L", name, where); return false; This is indeed sort of hackish and produces for testcase: program main complex :: c =3D 1. print *, atan (c,c) print *, atan2(c,c) end pr113412.f90:3:17: 3 | print *, atan (c,c) | 1 Error: 'x' argument of 'atan' intrinsic at (1) must be REAL pr113412.f90:4:17: 4 | print *, atan2(c,c) | 1 Error: 'y' argument of 'atan2' intrinsic at (1) must be REAL Note that the name of the formal argument is now wrong, probably because the association of actuals with formals is missing.=