<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Feb 13, 2015 at 8:43 PM, Edward Diener <span dir="ltr"><<a href="mailto:eldlistmailingz@tropicsoft.com" target="_blank">eldlistmailingz@tropicsoft.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 2/13/2015 11:17 PM, Nico Weber wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hans would know for sure, but I think this is intentional: Since AClass<br>
is dllexported, all its implicit functions get generated (so that they<br>
can be exported from the dll), which means they need to be semantically<br>
checked. If you give the class a deleted copy constructor and assignment<br>
operator, it might work.<br>
</blockquote>
<br></span>
Where in the C++ standard is such behavior justified ?<br></blockquote><div><br></div><div>You're using a non-standard feature (dllexport); the C++ standard's guarantees are not relevant.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The C++ standard does tell us I believe that if an object of a class is not copied there is never a need to specify a copy constructor and if a class is not assigned there is never a need to specify an assignment operator, whether or not one has a non-copyable or non-assignable member or not. Changing that basic rule to support something in clang related to "exported' classes cannot be correct IMO.<br>
<br>
Why does '__attribute__((__visibility__<u></u>("default")))' work but '__attribute__((dllexport))' does not ? Aren't they both the equivalent of "exporting" a class in clang ?<br>
<br>
I realize that for clang on Windows targeting mingw/gcc and not VC++ that the correct "export" attribute is probably '__attribute__((__visibility__<u></u>("default")))' and not '__attribute__((dllexport))'. But I heavily object to the idea that because I might be exporting a class the rules of copyability or assignability for that class must change contrary to the C++ standard. This also puts an extra conceptual burden on the design of a class.</blockquote><div><br></div><div>If our behavior doesn't match mingw here, that's probably a bug. IIRC, MS __declspec(dllexport) has the behavior of triggering the defintiions of all implicit special member functions, but it's possible that __attribute__((dllexport)) should not do the same thing.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
On Fri, Feb 13, 2015 at 8:07 PM, Edward Diener<br>
<<a href="mailto:eldlistmailingz@tropicsoft.com" target="_blank">eldlistmailingz@tropicsoft.<u></u>com</a><br></span><span class="">
<mailto:<a href="mailto:eldlistmailingz@tropicsoft.com" target="_blank">eldlistmailingz@<u></u>tropicsoft.com</a>>> wrote:<br>
<br>
I am compiling code with "-c -x c++ -O0 -g -fno-inline -Wall -g"<br>
using clang targeting mingw/gcc on Windows.<br>
<br>
This code compiles with no errors ( boost::scoped_ptr<T> is<br>
non-copyable, non-assignable ):<br>
<br>
#include <boost/scoped_ptr.hpp><br>
class<br>
AClass { boost::scoped_ptr<int> sp_pointer; };<br>
int main() { return 0; }<br>
<br>
This code compiles with no errors:<br>
<br>
#include <boost/scoped_ptr.hpp><br></span>
class __attribute__((__visibility__(<u></u>__"default")))<span class=""><br>
AClass { boost::scoped_ptr<int> sp_pointer; };<br>
int main() { return 0; }<br>
<br>
but this code compiles with errors:<br>
<br>
#include <boost/scoped_ptr.hpp><br>
class __attribute__((dllexport))<br>
AClass { boost::scoped_ptr<int> sp_pointer; };<br>
int main() { return 0; }<br>
<br>
test_clang_bug.cpp:3:1: error: field of type<br>
'boost::scoped_ptr<int>' has private copy constructor<br>
AClass { boost::scoped_ptr<int> sp_pointer; };<br>
^<br></span>
..\..\..\boost/smart_ptr/__<u></u>scoped_ptr.hpp:47:5: note: declared<span class=""><br>
private here<br>
scoped_ptr(scoped_ptr const &);<br>
^<br>
test_clang_bug.cpp:3:1: note: implicit copy constructor for<br>
'AClass' first required here<br>
AClass { boost::scoped_ptr<int> sp_pointer; };<br>
^<br>
test_clang_bug.cpp:3:1: error: 'operator=' is a private member<br>
of 'boost::scoped_ptr<int>'<br>
AClass { boost::scoped_ptr<int> sp_pointer; };<br>
^<br></span>
..\..\..\boost/smart_ptr/__<u></u>scoped_ptr.hpp:48:18: note: declared<span class=""><br>
private here<br>
scoped_ptr & operator=(scoped_ptr const &);<br>
^<br>
test_clang_bug.cpp:3:1: note: implicit copy assignment operator<br>
for 'AClass' first required here<br>
AClass { boost::scoped_ptr<int> sp_pointer; };<br>
^<br>
2 errors generated.<br>
<br>
<br>
Comments ?<br>
<br>
Should I file a bug report ?<br>
<br>
I do not see why, even "exporting" a class, clang should give an<br>
error. If I am not copying/assigning an instance of a class I should<br>
never get a compiler error telling me that some member is not<br>
copyable or assignable.<br>
<br></span>
______________________________<u></u>___________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<mailto:<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a>><br>
<a href="http://lists.cs.uiuc.edu/__mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/__<u></u>mailman/listinfo/cfe-dev</a><br>
<<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/cfe-dev</a>><span class=""><br>
<br>
<br>
<br>
<br>
______________________________<u></u>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/cfe-dev</a><br>
<br>
</span></blockquote><div class="HOEnZb"><div class="h5">
<br>
<br>
______________________________<u></u>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/cfe-dev</a><br>
</div></div></blockquote></div><br></div></div>