Thread overview
[Issue 16084] Linker error, not failed compilation, with interface final function calling virtual template function
[Issue 16084] Linker error with interface final function calling virtual function
May 27, 2016
Vladimir Panteleev
May 28, 2016
Jack Stouffer
May 28, 2016
Vladimir Panteleev
May 31, 2016
Jack Stouffer
May 31, 2016
Jack Stouffer
Nov 09, 2022
RazvanN
Dec 17, 2022
Iain Buclaw
May 27, 2016
https://issues.dlang.org/show_bug.cgi?id=16084

Vladimir Panteleev <thecybershadow@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |link-failure
                 CC|                            |thecybershadow@gmail.com

--- Comment #1 from Vladimir Panteleev <thecybershadow@gmail.com> ---
How can this code be valid? You are declaring a templated function with no implementation. Templated functions cannot be virtual. I think this shouldn't even compile.

--
May 28, 2016
https://issues.dlang.org/show_bug.cgi?id=16084

--- Comment #2 from Jack Stouffer <jack@jackstouffer.com> ---
(In reply to Vladimir Panteleev from comment #1)
> How can this code be valid?

According to the spec ;)

> You are declaring a templated function with no
> implementation. Templated functions cannot be virtual. I think this
> shouldn't even compile.

If non final template functions aren't possible, then the compiler must check for this and the spec needs to be updated.

I would like to know why this isn't possible though.

--
May 28, 2016
https://issues.dlang.org/show_bug.cgi?id=16084

--- Comment #3 from Vladimir Panteleev <thecybershadow@gmail.com> ---
(In reply to Jack Stouffer from comment #2)
> (In reply to Vladimir Panteleev from comment #1)
> > How can this code be valid?
> 
> According to the spec ;)

It may be syntactically valid but it is semantically useless.

> > You are declaring a templated function with no
> > implementation. Templated functions cannot be virtual. I think this
> > shouldn't even compile.
> 
> If non final template functions aren't possible, then the compiler must check for this and the spec needs to be updated.

I think final is implied for template methods.

> I would like to know why this isn't possible though.

Because the compiler must generate a virtual function call table entry for every instantiation, but it can't do that unless it knows the instantiations ahead of time (i.e. which template arguments will that template be instantiated with ANYWHERE in the program). This is something that would only be possible if the D compiler had access to the source code of the entire program during compilation, which is not how it works currently (and would preclude partial compilation to machine code).

--
May 31, 2016
https://issues.dlang.org/show_bug.cgi?id=16084

Jack Stouffer <jack@jackstouffer.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic

--- Comment #4 from Jack Stouffer <jack@jackstouffer.com> ---
Ok, I am changing this to an improved error message request. Also, IMO it should be mentioned on the interface page of the spec that template functions that don't use the interface template parameters are auto marked as final.

--
May 31, 2016
https://issues.dlang.org/show_bug.cgi?id=16084

Jack Stouffer <jack@jackstouffer.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
            Summary|Linker error with interface |Linker error, not failed
                   |final function calling      |compilation, with interface
                   |virtual function            |final function calling
                   |                            |virtual template function

--
November 09, 2022
https://issues.dlang.org/show_bug.cgi?id=16084

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |bootcamp
                 CC|                            |razvan.nitu1305@gmail.com

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

Iain Buclaw <ibuclaw@gdcproject.org> changed:

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

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

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

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

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

--