<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - A data member reached by several paths through a multiple inheritance does not receive maximum access"
href="https://llvm.org/bugs/show_bug.cgi?id=30604">30604</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>A data member reached by several paths through a multiple inheritance does not receive maximum access
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.8
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++11
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>iliyaaizin@mail.tau.ac.il
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>In the following code:
//////////////////////////
struct S2
{
int n = 1;
};
struct S3: virtual S2 {};
struct S4: virtual S3 {};
struct S6: protected S4, virtual S3 {};
int main (int argc, char* argv[])
{
S6 obj;
int num = obj.n;
return 0;
}
///////////////////////////////
data member n is inherited twice by S6, once public and once protected.
According to C++11 standard, section 11.6 [class.paths]: the access is that of
the path that gives most access. That means n should by public in S6, and
therefor accessible from main.
But we get the following compilation error:
////////////////////////////////////////////
clang.cpp:13:12: error: cannot cast 'S6' to its protected base class 'S2'
int num = obj.n;
^
clang.cpp:8:12: note: constrained by protected inheritance here
struct S6: protected S4, virtual S3 {};
^~~~~~~~~~~~
clang.cpp:13:16: error: 'n' is a protected member of 'S2'
int num = obj.n;
^
clang.cpp:8:12: note: constrained by protected inheritance here
struct S6: protected S4, virtual S3 {};
^~~~~~~~~~~~
clang.cpp:3:8: note: member is declared here
int n = 1;
^
2 errors generated.
/////////////////////////////////////////////////
The command used to compile is: clang file.cpp -std=c++11 -o file.exe
Compiler version:
clang version 3.8.1 (branches/release_38)
Target: i686-pc-windows-msvc
Thread model: posix</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>