Thread overview
[Issue 19196] DMD thinks storage size for pointer or dynamic array is unknown
Aug 27, 2018
Abscissa
Aug 27, 2018
Abscissa
[Issue 19196] DMD thinks storage size for pointer or dynamic array isn't always known
Aug 27, 2018
Abscissa
Aug 27, 2018
|
Aug 27, 2018
|
Dec 17, 2022
Iain Buclaw
August 27, 2018
https://issues.dlang.org/show_bug.cgi?id=19196

Abscissa <bus_dlangzilla@semitwist.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|DMD thinks storage size of  |DMD thinks storage size for
                   |dynamic array is unknown    |pointer or dynamic array is
                   |                            |unknown

--- Comment #1 from Abscissa <bus_dlangzilla@semitwist.com> ---
Same result if "Foo!(A)[]" is changed to "Foo!(A)*"

--
August 27, 2018
https://issues.dlang.org/show_bug.cgi?id=19196

Abscissa <bus_dlangzilla@semitwist.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |340


Referenced Issues:

https://issues.dlang.org/show_bug.cgi?id=340
[Issue 340] [Tracker] Forward reference bugs and other order-of-declaration
issues
--
August 27, 2018
https://issues.dlang.org/show_bug.cgi?id=19196

Abscissa <bus_dlangzilla@semitwist.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|DMD thinks storage size for |DMD thinks storage size for
                   |pointer or dynamic array is |pointer or dynamic array
                   |unknown                     |isn't always known

--
August 27, 2018
https://issues.dlang.org/show_bug.cgi?id=19196

| <dhasenan@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dhasenan@gmail.com

--- Comment #2 from | <dhasenan@gmail.com> ---
Reduced testcase that doesn't rely on phobos:

---
struct Foo(T)
{
    alias F = typeof(T.tupleof);
}

struct B
{
        // Error: struct `test.A` no size because of forward reference
        Foo!(B)[] arr;
}
---

In typesem.d:3495, we call `mt.sym.size(e.loc);`. We use it as a shortcut to run semantic analysis on the type before getting the type tuple. This results in a bad error message, but it's straightforward to improve that error message.

Obviously, some stuff won't fly, so we can't glibly leave everything to a later semantic step. The fix required to make this work fully is to run minimal semantic analysis during tupleof, lazily finish that semantic analysis, and only error out then.

That would catch the obvious problem of:

---
struct Foo
{
  static if (!hasElaborateDestructor!B) ~this() {}
}
struct B
{
  Foo foo;
}
---

But would let the original example compile.

Unfortunately, that level of change is beyond me at the moment.

--
August 27, 2018
https://issues.dlang.org/show_bug.cgi?id=19196

--- Comment #3 from | <dhasenan@gmail.com> ---
Created PR https://github.com/dlang/dmd/pull/8623

--
September 06, 2018
https://issues.dlang.org/show_bug.cgi?id=19196

--- Comment #4 from github-bugzilla@puremagic.com ---
Commit pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/379446e0f059d25e8da909bf5373f861af5069c5 Improve diagnostic with forward references and tupleof

When using tupleof in a template forward reference context, dmd emitted an error message complaining that it could not calculate the size of the struct. This happened even in cases when the size was not obviously required.

To make things less confusing and workarounds more obvious, the error message now explicitly says that tupleof is the problem.

Relates to (but doesn't fix) issue 19196.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=19196

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
December 13
https://issues.dlang.org/show_bug.cgi?id=19196

--- Comment #5 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19480

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--