From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6F67E388F07E; Mon, 18 May 2020 14:12:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6F67E388F07E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1589811142; bh=0R263KZ3HB9vvNswMaQ/ZWNKXUGKbA0DQqrUbtoAhf0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZRVonaVbZ9GfE6EWa1yvatZTTRh09kNu4/Zpr6TbA1xWVSFcwn79No3svfG1CECDd QkR5AbpKhlQMqvhDn1xuHHYxWw3ulY8T4RWHeaBwHRhyrcMWDXPQFW4z1CnibEz69O eq9vygMhIyCF9l8R7k3R13SgXZ2tNe6Ns1Xdycuo= From: "ibuclaw at gdcproject dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug d/95174] [D] Incorrect compiled functions involving const fixed size arrays Date: Mon, 18 May 2020 14:12:22 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: d X-Bugzilla-Version: 9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ibuclaw at gdcproject dot org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: ibuclaw at gdcproject dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: resolution bug_status 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: Mon, 18 May 2020 14:12:22 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95174 Iain Buclaw changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #1 from Iain Buclaw --- (In reply to Witold Baryluk from comment #0) > https://explore.dgnu.org/z/LppySp >=20 >=20 [--snip--] >=20 > Is incorrectly compiled to 'nop; ret' >=20 It is correct, all those functions do nothing. What you're missing is a 'r= ef' or 'out' storage class on the 'o' parameter. Rationale, static arrays are value types in D (they don't saturate to point= ers like in C). See https://dlang.org/spec/arrays.html#static-arrays >=20 > As a bonus: >=20 > ``` > void fffff(immutable(float[4]) x, float[4] o) { > o[2] =3D x[1] + x[3]; > } >=20 > import std.stdio : writeln; >=20 > void main() { > immutable(float[4]) k =3D [7.0f, 5.3f, 1.2f, 3.2f]; > float[4] o; > fffff(k, o); > writeln(o); > } >=20 > ``` >=20 > prints '[nan, nan, nan, nan]', but it should: '[nan, nan, 8.5, nan]'. >=20 >=20 All NaNs is the correct result here too.=