[cfe-dev] Interesting clang behavior/bug? on Windows

Nico Weber thakis at chromium.org
Fri Feb 13 20:17:02 PST 2015


Hans would know for sure, but I think this is intentional: Since AClass is
dllexported, all its implicit functions get generated (so that they can be
exported from the dll), which means they need to be semantically checked.
If you give the class a deleted copy constructor and assignment operator,
it might work.

On Fri, Feb 13, 2015 at 8:07 PM, Edward Diener <
eldlistmailingz at tropicsoft.com> wrote:

> I am compiling code with "-c -x c++ -O0 -g -fno-inline -Wall -g"
> using clang targeting mingw/gcc on Windows.
>
> This code compiles with no errors ( boost::scoped_ptr<T> is non-copyable,
> non-assignable ):
>
> #include <boost/scoped_ptr.hpp>
> class
> AClass { boost::scoped_ptr<int> sp_pointer; };
> int main()  {  return 0;  }
>
> This code compiles with no errors:
>
> #include <boost/scoped_ptr.hpp>
> class __attribute__((__visibility__("default")))
> AClass { boost::scoped_ptr<int> sp_pointer; };
> int main()  {  return 0;  }
>
> but this code compiles with errors:
>
> #include <boost/scoped_ptr.hpp>
> class __attribute__((dllexport))
> AClass { boost::scoped_ptr<int> sp_pointer; };
> int main()  {  return 0;  }
>
>  test_clang_bug.cpp:3:1: error: field of type 'boost::scoped_ptr<int>' has
>> private copy constructor
>> AClass { boost::scoped_ptr<int> sp_pointer; };
>> ^
>> ..\..\..\boost/smart_ptr/scoped_ptr.hpp:47:5: note: declared private here
>>     scoped_ptr(scoped_ptr const &);
>>     ^
>> test_clang_bug.cpp:3:1: note: implicit copy constructor for 'AClass'
>> first required here
>> AClass { boost::scoped_ptr<int> sp_pointer; };
>> ^
>> test_clang_bug.cpp:3:1: error: 'operator=' is a private member of
>> 'boost::scoped_ptr<int>'
>> AClass { boost::scoped_ptr<int> sp_pointer; };
>> ^
>> ..\..\..\boost/smart_ptr/scoped_ptr.hpp:48:18: note: declared private
>> here
>>     scoped_ptr & operator=(scoped_ptr const &);
>>                  ^
>> test_clang_bug.cpp:3:1: note: implicit copy assignment operator for
>> 'AClass' first required here
>> AClass { boost::scoped_ptr<int> sp_pointer; };
>> ^
>> 2 errors generated.
>>
>
> Comments ?
>
> Should I file a bug report ?
>
> I do not see why, even "exporting" a class, clang should give an error. If
> I am not copying/assigning an instance of a class I should never get a
> compiler error telling me that some member is not copyable or assignable.
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150213/2549dea6/attachment.html>


More information about the cfe-dev mailing list