On Wednesday, 10 August 2016 at 15:39:19 UTC, Arafel wrote:
On Wednesday, 10 August 2016 at 15:25:40 UTC, Lodovico Giaretta wrote:
Because templated functions cannot be virtual, it follows that I.func is final. Having no body, the compiler thinks that its body will be found by the linker in another object file, but this does not happen, so the linker complains. Being I.func final, C.func just hides it, so you would not incur any problem if you called func explicitly on an object of type C.

So what you found is not a bug, but some unintuitive behaviour due to templated functions being implicitly final and forward declarations. Maybe the compiler should emit a warning about implicitly-final functions in interfaces.

Would it even make sense to "force" (deprecation warning) a "final" keyword in any implicitly-final function (I wasn't even aware of those, I have to admit)? It would make things much clearer, like with "override"...

I read the spec again, and found out that it says interfaces cannot contain templated functions... So either my interpretation is the intended one and the spec is outdated, or the spec is right and the compiler is bugged.

Reply via email to