[llvm-bugs] [Bug 32074] New: Clang accepts copy constructor when the copy constructor is declared incorrectly
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Feb 26 22:51:17 PST 2017
http://bugs.llvm.org/show_bug.cgi?id=32074
Bug ID: 32074
Summary: Clang accepts copy constructor when the copy
constructor is declared incorrectly
Product: clang
Version: unspecified
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: hughbellars at gmail.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
The following code compiles fine with Clang (3.9.1). GCC (7, snapshot) and MSVC
(Visual Studio 2015 Update 3) correctly identify this as a badly formed copy
constructor and don't compile this. Obviously fixing this would be a breaking
change. However, it's successful compilation causes portability issues:
https://github.com/apple/swift/pull/7762
template <bool refcountIsInline>
class RefCountBitsT {
RefCountBitsT(RefCountBitsT<true> newbits) { }
};
class SideTableRefCountBits : public RefCountBitsT<false> {
SideTableRefCountBits(RefCountBitsT<true> newbits)
: RefCountBitsT<false>(newbits) {}
};
GCC emits:
source_file.cpp: In instantiation of ‘class RefCountBitsT<true>’:
source_file.cpp:3:48: required from here
source_file.cpp:3:5: error: invalid constructor; you probably meant
‘RefCountBitsT<true> (const RefCountBitsT<true>&)’
RefCountBitsT(RefCountBitsT<true> newbits) { }
^
source_file.cpp: In constructor
‘SideTableRefCountBits::SideTableRefCountBits(RefCountBitsT<true>)’:
source_file.cpp:3:5: error:
‘RefCountBitsT<refcountIsInline>::RefCountBitsT(RefCountBitsT<true>) [with bool
refcountIsInline = false]’ is private
source_file.cpp:8:39: error: within this context
: RefCountBitsT<false>(newbits) {}
^
source_file.cpp:8:39: error: call of overloaded
‘RefCountBitsT(RefCountBitsT<true>&)’ is ambiguous
source_file.cpp:3:5: note: candidate:
RefCountBitsT<refcountIsInline>::RefCountBitsT(RefCountBitsT<true>) [with bool
refcountIsInline = true]
RefCountBitsT(RefCountBitsT<true> newbits) { }
^
source_file.cpp:2:7: note: candidate: constexpr
RefCountBitsT<true>::RefCountBitsT(const RefCountBitsT<true>&)
class RefCountBitsT {
^
source_file.cpp:3:5: note: initializing argument 1 of
‘RefCountBitsT<refcountIsInline>::RefCountBitsT(RefCountBitsT<true>) [with bool
refcountIsInline = false]’
RefCountBitsT(RefCountBitsT<true> newbits) { }
MSVC emits:
source_file.cpp(3): error C2652: 'RefCountBitsT<true>': illegal copy
constructor: first parameter must not be a 'RefCountBitsT<true>'
source_file.cpp(7): note: see reference to class template instantiation
'RefCountBitsT<true>' being compiled
source_file.cpp(3): error C2333: 'RefCountBitsT<true>::RefCountBitsT': error in
function declaration; skipping function body
source_file.cpp(7): error C2664:
'RefCountBitsT<false>::RefCountBitsT(RefCountBitsT<false> &&)': cannot convert
argument 1 from 'RefCountBitsT<true>' to 'RefCountBitsT<true>'
source_file.cpp(7): note: Cannot copy construct class 'RefCountBitsT<true>' due
to ambiguous copy constructors or no available copy constructor
--
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/20170227/2092f741/attachment.html>
More information about the llvm-bugs
mailing list