[Issue 23259] New: Visibility violation with variadic templates
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jul 19 08:51:51 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23259
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 at puremagic.com
Reporter: lucien.perregaux at gmail.com
In the following code, private methods are called instead of public ones :
```
import std.stdio;
class C(T, Args...)
{
private:
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 !");
}
public:
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);
c.f!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).
--
More information about the Digitalmars-d-bugs
mailing list