public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug d/108055] New: d: Undefined reference to nested lambda in template
@ 2022-12-10 20:26 ibuclaw at gdcproject dot org
2022-12-12 19:25 ` [Bug d/108055] " cvs-commit at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: ibuclaw at gdcproject dot org @ 2022-12-10 20:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108055
Bug ID: 108055
Summary: d: Undefined reference to nested lambda in template
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: d
Assignee: ibuclaw at gdcproject dot org
Reporter: ibuclaw at gdcproject dot org
Target Milestone: ---
issue.d:
---
import std.conv;
void main()
{
float* zis ;
static if (is(typeof(to!string(*zis))))
to!string(*zis);
}
---
std/conv.d:
---
T toStr(T, S)(S src)
{
static if (is(typeof(T.init[0]) E))
{
struct Appender
{
inout(E)[] data;
}
import std.format.spec;
import std.format.write;
auto w = Appender();
FormatSpec!E f;
formatValue(w, src, f);
return w.data;
}
}
T to(T, A)(A args)
{
return toStr!T(args);
}
---
std/format/spec.d:
---
module std.format.spec;
template Unqual(T : const U, U)
{
alias Unqual = U;
}
template FormatSpec(Char)
if (!is(Unqual!Char == Char))
{
alias FormatSpec = FormatSpec!(Unqual!Char);
}
struct FormatSpec(Char)
if (is(Unqual!Char == Char))
{
const(Char)[] nested;
}
---
std/format/write.d:
---
module std.format.write;
import std.format.spec;
void formatValueImpl(Writer, T, Char)(ref Writer , const(T) ,
scope const ref FormatSpec!Char )
{
T val;
char spec;
(ref val) @trusted {
return (cast(const char*) &val)[0 .. val.sizeof];
}(val);
}
void formatValue(Writer, T, Char)(Writer w, T val, Char f)
{
formatValueImpl(w, val, f);
}
---
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug d/108055] d: Undefined reference to nested lambda in template
2022-12-10 20:26 [Bug d/108055] New: d: Undefined reference to nested lambda in template ibuclaw at gdcproject dot org
@ 2022-12-12 19:25 ` cvs-commit at gcc dot gnu.org
2022-12-12 19:25 ` cvs-commit at gcc dot gnu.org
2022-12-12 19:29 ` ibuclaw at gdcproject dot org
2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-12-12 19:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108055
--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:
https://gcc.gnu.org/g:9fe7d3debbf60ed9fef8053123ad542a99d62100
commit r13-4622-g9fe7d3debbf60ed9fef8053123ad542a99d62100
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Sat Dec 10 22:11:41 2022 +0100
d: Fix undefined reference to nested lambda in template (PR108055)
Sometimes, nested lambdas of templated functions get no code generation
due to them being marked as instantianted outside of all modules being
compiled in the current compilation unit. This despite enclosing
template instances being marked as instantiated inside the current
compilation unit. To fix, all enclosing templates are now checked in
`function_defined_in_root_p'.
Because of this change, `function_needs_inline_definition_p' has also
been fixed up to only check whether the regular function definition
itself is to be emitted in the current compilation unit.
PR d/108055
gcc/d/ChangeLog:
* decl.cc (function_defined_in_root_p): Check all enclosing
template
instances for definition in a root module.
(function_needs_inline_definition_p): Replace call to
function_defined_in_root_p with test for outer module `isRoot'.
gcc/testsuite/ChangeLog:
* gdc.dg/torture/imports/pr108055conv.d: New.
* gdc.dg/torture/imports/pr108055spec.d: New.
* gdc.dg/torture/imports/pr108055write.d: New.
* gdc.dg/torture/pr108055.d: New test.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug d/108055] d: Undefined reference to nested lambda in template
2022-12-10 20:26 [Bug d/108055] New: d: Undefined reference to nested lambda in template ibuclaw at gdcproject dot org
2022-12-12 19:25 ` [Bug d/108055] " cvs-commit at gcc dot gnu.org
@ 2022-12-12 19:25 ` cvs-commit at gcc dot gnu.org
2022-12-12 19:29 ` ibuclaw at gdcproject dot org
2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-12-12 19:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108055
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Iain Buclaw
<ibuclaw@gcc.gnu.org>:
https://gcc.gnu.org/g:3b8b42f32627ca5ad029fe418a5839b9fc4512e9
commit r12-8980-g3b8b42f32627ca5ad029fe418a5839b9fc4512e9
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Sat Dec 10 22:11:41 2022 +0100
d: Fix undefined reference to nested lambda in template (PR108055)
Sometimes, nested lambdas of templated functions get no code generation
due to them being marked as instantianted outside of all modules being
compiled in the current compilation unit. This despite enclosing
template instances being marked as instantiated inside the current
compilation unit. To fix, all enclosing templates are now checked in
`function_defined_in_root_p'.
Because of this change, `function_needs_inline_definition_p' has also
been fixed up to only check whether the regular function definition
itself is to be emitted in the current compilation unit.
PR d/108055
gcc/d/ChangeLog:
* decl.cc (function_defined_in_root_p): Check all enclosing
template
instances for definition in a root module.
(function_needs_inline_definition_p): Replace call to
function_defined_in_root_p with test for outer module `isRoot'.
gcc/testsuite/ChangeLog:
* gdc.dg/torture/imports/pr108055conv.d: New.
* gdc.dg/torture/imports/pr108055spec.d: New.
* gdc.dg/torture/imports/pr108055write.d: New.
* gdc.dg/torture/pr108055.d: New test.
(cherry picked from commit 9fe7d3debbf60ed9fef8053123ad542a99d62100)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug d/108055] d: Undefined reference to nested lambda in template
2022-12-10 20:26 [Bug d/108055] New: d: Undefined reference to nested lambda in template ibuclaw at gdcproject dot org
2022-12-12 19:25 ` [Bug d/108055] " cvs-commit at gcc dot gnu.org
2022-12-12 19:25 ` cvs-commit at gcc dot gnu.org
@ 2022-12-12 19:29 ` ibuclaw at gdcproject dot org
2 siblings, 0 replies; 4+ messages in thread
From: ibuclaw at gdcproject dot org @ 2022-12-12 19:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108055
Iain Buclaw <ibuclaw at gdcproject dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |FIXED
--- Comment #3 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
Fix committed and backported.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-12-12 19:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-10 20:26 [Bug d/108055] New: d: Undefined reference to nested lambda in template ibuclaw at gdcproject dot org
2022-12-12 19:25 ` [Bug d/108055] " cvs-commit at gcc dot gnu.org
2022-12-12 19:25 ` cvs-commit at gcc dot gnu.org
2022-12-12 19:29 ` ibuclaw at gdcproject dot org
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).