<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 --- - regression, using parent constructor enables illegal implicit casts"
href="https://llvm.org/bugs/show_bug.cgi?id=31606">31606</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>regression, using parent constructor enables illegal implicit casts
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.9
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>FreeBSD
</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++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>kamikaze@bsdforen.de
</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>Created <span class=""><a href="attachment.cgi?id=17829" name="attach_17829" title="Minimal testcase">attachment 17829</a> <a href="attachment.cgi?id=17829&action=edit" title="Minimal testcase">[details]</a></span>
Minimal testcase
For context, here is the attached test case:
~~~
struct Base {};
struct A : Base {
using Base::Base;
bool operator ==(A const&) const;
};
struct B : Base {
using Base::Base;
};
bool foo() {
return A{} == A{} &&
A{} == B{};
}
~~~
The provided test case compiles with clang++39:
~~~
# clang++39 -std=c++11 -c test.cpp -o test.o
#
~~~
I expect it to fail, e.g. with clang++38:
~~~
# clang++38 -std=c++11 -c test.cpp -o test.o
test.cpp:14:13: error: invalid operands to binary expression ('A' and 'B')
A{} == B{};
~~~ ^ ~~~
test.cpp:5:7: note: candidate function not viable: no known conversion from 'B'
to 'const A' for 1st argument
bool operator ==(A const&) const;
^
1 error generated.
#
~~~
Or GCC:
~~~
# g++5 -std=c++11 -c test.cpp -o test.o
test.cpp: In function 'bool foo()':
test.cpp:14:13: error: no match for 'operator==' (operand types are 'A' and
'B')
A{} == B{};
^
test.cpp:5:7: note: candidate: bool A::operator==(const A&) const
bool operator ==(A const&) const;
^
test.cpp:5:7: note: no known conversion for argument 1 from 'B' to 'const A&'
#
~~~
This triggers some static_asserts() with SFINAE tests in one of my projects, it
took me a while to decouple the problem from all the template-fu.
Here is the relevant system info:
# uname -a
FreeBSD AprilRyan.norad 11.0-STABLE FreeBSD 11.0-STABLE #0 r311880: Tue Jan 10
22:24:08 CET 2017 <a href="mailto:root@AprilRyan.norad">root@AprilRyan.norad</a>:/usr/obj/S403/amd64/usr/src/sys/S403
amd64
# clang++39 -v
clang version 3.9.1 (tags/RELEASE_391/final)
Target: x86_64-unknown-freebsd11.0
Thread model: posix
InstalledDir: /usr/local/llvm39/bin
# clang++38 -v
clang version 3.8.1 (tags/RELEASE_381/final)
Target: x86_64-unknown-freebsd11.0
Thread model: posix
InstalledDir: /usr/local/llvm38/bin
# g++5 -v
Using built-in specs.
COLLECT_GCC=g++5
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc5/gcc/x86_64-portbld-freebsd11.0/5.4.0/lto-wrapper
Target: x86_64-portbld-freebsd11.0
Configured with: /tmp/obj/usr/ports/lang/gcc5/work/gcc-5.4.0/configure
--disable-bootstrap --disable-nls --enable-gnu-indirect-function
--libdir=/usr/local/lib/gcc5 --libexecdir=/usr/local/libexec/gcc5
--program-suffix=5 --with-as=/usr/local/bin/as --with-gmp=/usr/local
--with-gxx-include-dir=/usr/local/lib/gcc5/include/c++/
--with-ld=/usr/local/bin/ld --with-pkgversion='FreeBSD Ports Collection'
--with-system-zlib --disable-libgcj --enable-languages=c,c++,objc,fortran
--prefix=/usr/local --localstatedir=/var --mandir=/usr/local/man
--infodir=/usr/local/info/gcc5 --build=x86_64-portbld-freebsd11.0
Thread model: posix
gcc version 5.4.0 (FreeBSD Ports Collection)</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>