<html>
    <head>
      <base href="http://bugs.llvm.org/">
    </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 - Clang accepts copy constructor when the copy constructor is declared incorrectly"
   href="http://bugs.llvm.org/show_bug.cgi?id=32074">32074</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang accepts copy constructor when the copy constructor is declared incorrectly
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </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>hughbellars@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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:
<a href="https://github.com/apple/swift/pull/7762">https://github.com/apple/swift/pull/7762</a>


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</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>