<html>
    <head>
      <base href="https://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 - Bad diagnostic when trying to copy an uncopyable type"
   href="https://bugs.llvm.org/show_bug.cgi?id=41819">41819</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Bad diagnostic when trying to copy an uncopyable type
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </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>barry.revzin@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Same issue as gcc's bug (<a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90413">https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90413</a>):

template<class T>
struct Bar {
    Bar() {}
    Bar(const Bar&) {
        static_assert(sizeof(T) == 1, "");
    }
};
template<class T>
struct Foo {
    Foo() {}
#ifdef DEFAULT
    Foo(const Foo&) = default;
#else
    Foo(const Foo& o) : b(o.b) {}
#endif
    Bar<T> b;
};

int main() { 
    Foo<int> f;
    Foo<int> g = f;
}

Without -DDEFAULT, the error points to the offending line (you can see the
construction of 'g' in the error trace):

source>:5:9: error: static_assert failed due to requirement 'sizeof(int) == 1'
""
        static_assert(sizeof(T) == 1, "");
        ^             ~~~~~~~~~~~~~~
<source>:14:25: note: in instantiation of member function 'Bar<int>::Bar'
requested here
    Foo(const Foo& o) : b(o.b) {}
                        ^
<source>:21:18: note: in instantiation of member function 'Foo<int>::Foo'
requested here
    Foo<int> g = f;
                 ^
1 error generated.
Compiler returned: 1

With -DDEFAULT, the error does not point to the offending line at all:

source>:5:9: error: static_assert failed due to requirement 'sizeof(int) == 1'
""
        static_assert(sizeof(T) == 1, "");
        ^             ~~~~~~~~~~~~~~
<source>:12:5: note: in instantiation of member function 'Bar<int>::Bar'
requested here
    Foo(const Foo&) = default;
    ^
1 error generated.
Compiler returned: 1

In larger examples, this makes it very hard to determine the actual source of
problem -- since it doesn't even appear.</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>