[cfe-dev] Interesting clang behavior/bug? on Windows
Edward Diener
eldlistmailingz at tropicsoft.com
Fri Feb 13 20:07:53 PST 2015
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.
More information about the cfe-dev
mailing list