[llvm-bugs] [Bug 39284] New: Non-static member access where naming class is a sibling class of the object

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Oct 13 20:52:50 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=39284

            Bug ID: 39284
           Summary: Non-static member access where naming class is a
                    sibling class of the object
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hstong at ca.ibm.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

[class.access.base] stipulates that the conversion from a pointer to the class
object on which a class member access is performed to a "pointer to the the
naming class type" shall exist.

Clang does not enforce that rule. With Clang, it is possible to access a member
of a class object while naming the member as a member of a sibling (or derived)
class.

### SOURCE (<stdin>):
struct A { int x; };
struct B : A { };
struct C : A { };

C c;
int main(void) { return c.::B::x; }


### COMPILER INVOCATION:
clang -cc1 -xc++ -


### ACTUAL OUTPUT:
(Compiles successfully).


### EXPECTED OUTPUT:
(Compiler diagnostic).


### COMPILER VERSION INFO (clang -v):
clang version 8.0.0 (https://github.com/llvm-mirror/clang.git
0bb96efa2d32678d0ac578363b78611074630787)
(https://github.com/llvm-mirror/llvm.git
2141d146188bfbfce6917ff11f606de819b57d52)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/wandbox/clang-head/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.0.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181014/d36d4a26/attachment.html>


More information about the llvm-bugs mailing list