From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0B01E3858D28; Sat, 23 Mar 2024 19:56:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0B01E3858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1711223797; bh=0x+Cdn+XdWP81pZUSkwLsxdyTB+b9DForHz67VWOLhU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=gu14jAEIUXwTr4zDfALqAjG3WK5tpcVQil4WxFUF3BbxCyca6baQfWFOT3gLLwXMi aWHEhuv8LGRlpDd3aXDYaL4nRVBJLB3qF0Hjjy+dxTVUNvZPaWuNWT1MZRCtXwN9Xe +Rhp5sVVB5yz3upuOvBNxS1DW82ZfTRXPZksEKkE= From: "kargl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/114438] Missed constraint F2023:c7108 Date: Sat, 23 Mar 2024 19:56:36 +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: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kargl at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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=3D114438 --- Comment #2 from kargl at gcc dot gnu.org --- (In reply to anlauf from comment #1) > Can you be a little more explicit? >=20 > If I extend the program as follows: >=20 > type(params) :: p > p =3D params( 0.1, 2.0 ) > write(*,*) p > p =3D params( 0.1, 2 ) > write(*,*) p >=20 > I get with all compilers I have access to (Intel, NAG, Nvidia, flang, > gfortran) >=20 > Not the structure constructor > 0.100000001 4.00000000=20=20=20=20 > 0.100000001 2.00000000=20=20=20=20 >=20 > This is what I would have naively expected in accordance with "Note 1": >=20 > The form =E2=80=99name(...)=E2=80=99 is interpreted as a generic functi= on-reference if > possible; it is interpreted as a structure-constructor only if it cannot > be interpreted as a generic function-reference. >=20 > which gives a precedence to function-reference over structure-constructor, > making it possible to override the default constructor. >=20 > Are you saying that one cannot override the default constructor? I thought C7108 was clear. C7108 (R756) If derived-type-spec is a type name that is the same as a generic name, the component-spec-list shall not be a valid actual-arg-spec-list f= or a function reference that is resolvable as a generic reference to that name (15.5.5.2). The derived-type-spec is 'params'. The generic name is 'params'. The component-spec-list for the derived type in 'p =3D params(3.0,2.0)' has types of 'real' and 'real'. The generic reference is 'p =3D params(3.0,2.0)', which resolves to 'default_params'. 'default_params' has an actual-arg-spec-list with types of 'real' and 'real= '. Thus, 'params(real,real)' is ambiguous. Is it the structure constructor or a generic function reference? Note, you cannot use keywords as the components of the derive type 'params' are 'x' and 'y', and the dummy arguments for=20 'default_params' are also 'x' and 'y'. Finally, 'p =3D params(3,2.0)' is a structure constructor, because the generic interface does not include a function with types of 'integer' and 'real'. Thus, here, this is not a function reference. It must be a structure constructor. The rules of intrinsic assignment are now in play, and 'params(3,2.0)' is treated as 'params(3.0,2.0)'=20 after type conversion. Of course, I could be wrong.=