From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 91A803858D39; Sun, 12 Mar 2023 14:52:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 91A803858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678632751; bh=6bH4owD4iSo2rRk1SOk1QR4ux4rl1XmV1qbZkN5ultA=; h=From:To:Subject:Date:From; b=FJWwpqbQx9pj1cIY2mNUoN9gduI7nCGmFMMANNGTbutv5scWXhac+XKLmw2/1qowG 4AHX81XnNhmpZMRbD2sd8zyhg0VthUiKWhvP5gJeB/e6cY2Vm/Fmrow1airanrHSMp XCjKZ6O0ZAFAlNXxCBr97Lt9iIe7mJQDr5eFU8gI= From: "ibuclaw at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug d/109108] New: d: Undefined reference to lambda in private enum Date: Sun, 12 Mar 2023 14:52:31 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: d X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ibuclaw at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: ibuclaw at gdcproject dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D109108 Bug ID: 109108 Summary: d: Undefined reference to lambda in private enum Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: d Assignee: ibuclaw at gdcproject dot org Reporter: ibuclaw at gcc dot gnu.org Target Milestone: --- Similar to pr108055. Lambdas should be emitted in every module they are referenced from. ``` import other; void main() { auto a =3D callFun(1); } ``` ``` private enum int function(ref int)[] funs =3D [ 0: (ref idx) =3D> 0, 1: (ref idx) =3D> 1, ]; int callFun(I)(I idx) { return funs[idx](idx); } ``` Only compiling the "main" module results in linker errors. --- $ gdc test.d -Wl,--demangle=3Ddlang /usr/x86_64-pc-linux-gnu/bin/ld: /tmp/ccDW8iNw.o: in function `other.callFun!(int).callFun(int)': test.d:(.text+0x4b): undefined reference to `other.__lambda4!(int).__lambda4(ref int)' test.d:(.text+0x56): undefined reference to `other.__lambda5!(int).__lambda5(ref int)' collect2: error: ld returned 1 exit status=