public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ibuclaw at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-109108-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109108

            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 = callFun(1);
}
```

```
private enum int function(ref int)[] funs =
[
    0: (ref idx) => 0,
    1: (ref idx) => 1,
];

int callFun(I)(I idx)
{
    return funs[idx](idx);
}
```

Only compiling the "main" module results in linker errors.
---
$ gdc test.d -Wl,--demangle=dlang
/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

             reply	other threads:[~2023-03-12 14:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-12 14:52 ibuclaw at gcc dot gnu.org [this message]
2023-03-14 18:16 ` [Bug d/109108] " cvs-commit at gcc dot gnu.org
2023-03-14 19:11 ` cvs-commit at gcc dot gnu.org
2023-03-14 19:55 ` cvs-commit at gcc dot gnu.org
2023-03-14 20:18 ` ibuclaw at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-109108-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).