www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23259] New: Visibility violation with variadic templates


          Issue ID: 23259
           Summary: Visibility violation with variadic templates
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: lucien.perregaux gmail.com

In the following code, private methods are called instead of public ones :
import std.stdio;

class C(T, Args...)
        this(int i, Args args)
                assert(0, "private ctor should not be called !");

        void f(U, V...)(int i, V v)
                assert(0, "private function should not be called !");

        this(Args args)
                writeln("public ctor should be called !");

        void f(V...)(V v)
                writeln("public function should be called !");

void main()
        auto c = new C!string(8);


The compiler seems to check for any public matches and then call the most
specialized method, ignoring the visibility (`protected` and `package`
visibilities are also affected).

Jul 19 2022