[llvm-bugs] [Bug 28490] New: clang accepts illegal C++ code with ambiguous member lookup
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Jul 9 17:46:52 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=28490
Bug ID: 28490
Summary: clang accepts illegal C++ code with ambiguous member
lookup
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: su at cs.ucdavis.edu
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
Classification: Unclassified
The current clang trunk (and all versions at least as early as 2.9) accepts the
following C++ code, which should be illegal according to the C++ standard
because of ambiguous member lookup.
It is rejected by both GCC and MSVC (but accepted by ICC).
$ clang++ -v
clang version 3.9.0 (trunk 274972)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.3.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.1.1
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$
$ g++-6.1 -c small.cpp
small.cpp: In instantiation of ‘void C<T>::f() [with T = int]’:
small.cpp:13:7: required from here
small.cpp:7:16: error: request for member ‘i’ is ambiguous
void f () { i (); }
^
small.cpp:3:18: note: candidates are: void B::i()
struct B { void i () {} };
^
small.cpp:1:36: note: int A<int>::i
template < class > struct A { int i; };
^
$
$ clang++-2.9 -c small.cpp
$
$ clang++ -c small.cpp
$
-----------------------------------------------
template < class > struct A { int i; };
struct B { void i () {} };
template < class T > struct C : A < T >, B
{
void f () { i (); }
};
int main ()
{
C < int > c;
c.f();
return 0;
}
--
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/20160710/1647d931/attachment.html>
More information about the llvm-bugs
mailing list