[llvm-bugs] [Bug 31606] New: regression, using parent constructor enables illegal implicit casts

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jan 11 03:12:35 PST 2017


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

            Bug ID: 31606
           Summary: regression, using parent constructor enables illegal
                    implicit casts
           Product: clang
           Version: 3.9
          Hardware: PC
                OS: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kamikaze at bsdforen.de
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 17829
  --> https://llvm.org/bugs/attachment.cgi?id=17829&action=edit
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     root at AprilRyan.norad:/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)

-- 
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/20170111/199531f9/attachment.html>


More information about the llvm-bugs mailing list