V
Vladimir Jovic
Hello,
Compiling following example:
#include <string>
class A
{
public:
A(int)
{
}
A(...)
{
throw 111;
}
~A()
{
}
};
int main()
{
A a( 55 );
A b( std::string("aaa") ); // this doesn't work
}
would stop the compiler with next error output:
g++ yui.cpp
yui.cpp: In function ‘int main()’:
yui.cpp:23: warning: cannot pass objects of non-POD type ‘struct
std::string’ through ‘...’; call will abort at runtime
I tried modified the example to have a constructor as a template
function, but since I am using pimpl idiom, I am getting next error:
************
[vladimir@thuja projectCyclades]$ ./scripts/build_host_unit_test.sh
In file included from
/sandbox/vladimir/projectCyclades/_host_test/../utils/cxxtest/cxxtest/Root.cpp:17,
from
/sandbox/vladimir/projectCyclades/_host_test/./obj/a_sda/testgen/unit_test_runner.cpp:955:
/usr/lib/gcc/i386-redhat-linux/4.3.0/../../../../include/c++/4.3.0/backward/auto_ptr.h:
In destructor ‘std::auto_ptr<_Tp>::~auto_ptr() [with _Tp =
ezono::ccapp::sda::FilterLogCompression::Imp]’:
/sandbox/vladimir/projectCyclades/_host_test/../code/i_ptr/inco_ptr_autoptr.hpp:127:
instantiated from ‘ezono::inco:
tr::AutoPtr<T>::AutoPtr(T*) [with T
= ezono::ccapp::sda::FilterLogCompression::Imp]’
/sandbox/vladimir/projectCyclades/_host_test/../code/a_sda/ccapp_sda_filterlogcompression.hpp:119:
instantiated from
‘ezono::ccapp::sda::FilterLogCompression::FilterLogCompression(const
InBuffType&, OutBuffType&) [with InBuffType =
ezono::ccapp::sda::FilterBuffer<ezono::ccapp::sda::Buffer32Bits, false>,
OutBuffType =
ezono::ccapp::sda::FilterBuffer<ezono::ccapp::sda::Buffer8Bits, false>]’
/sandbox/vladimir/projectCyclades/_host_test/../code/a_sda/unittests/test_ccapp_sda_filterlogcompression.hpp:119:
instantiated from here
/usr/lib/gcc/i386-redhat-linux/4.3.0/../../../../include/c++/4.3.0/backward/auto_ptr.h:173:
note: neither the destructor nor the class-specific operator delete will
be called, even if they are declared when the class is defined.
************
I will create another example demonstrating this.
Is there a way to modify the example above to work for non-pod types?
Compiling following example:
#include <string>
class A
{
public:
A(int)
{
}
A(...)
{
throw 111;
}
~A()
{
}
};
int main()
{
A a( 55 );
A b( std::string("aaa") ); // this doesn't work
}
would stop the compiler with next error output:
g++ yui.cpp
yui.cpp: In function ‘int main()’:
yui.cpp:23: warning: cannot pass objects of non-POD type ‘struct
std::string’ through ‘...’; call will abort at runtime
I tried modified the example to have a constructor as a template
function, but since I am using pimpl idiom, I am getting next error:
************
[vladimir@thuja projectCyclades]$ ./scripts/build_host_unit_test.sh
In file included from
/sandbox/vladimir/projectCyclades/_host_test/../utils/cxxtest/cxxtest/Root.cpp:17,
from
/sandbox/vladimir/projectCyclades/_host_test/./obj/a_sda/testgen/unit_test_runner.cpp:955:
/usr/lib/gcc/i386-redhat-linux/4.3.0/../../../../include/c++/4.3.0/backward/auto_ptr.h:
In destructor ‘std::auto_ptr<_Tp>::~auto_ptr() [with _Tp =
ezono::ccapp::sda::FilterLogCompression::Imp]’:
/sandbox/vladimir/projectCyclades/_host_test/../code/i_ptr/inco_ptr_autoptr.hpp:127:
instantiated from ‘ezono::inco:
= ezono::ccapp::sda::FilterLogCompression::Imp]’
/sandbox/vladimir/projectCyclades/_host_test/../code/a_sda/ccapp_sda_filterlogcompression.hpp:119:
instantiated from
‘ezono::ccapp::sda::FilterLogCompression::FilterLogCompression(const
InBuffType&, OutBuffType&) [with InBuffType =
ezono::ccapp::sda::FilterBuffer<ezono::ccapp::sda::Buffer32Bits, false>,
OutBuffType =
ezono::ccapp::sda::FilterBuffer<ezono::ccapp::sda::Buffer8Bits, false>]’
/sandbox/vladimir/projectCyclades/_host_test/../code/a_sda/unittests/test_ccapp_sda_filterlogcompression.hpp:119:
instantiated from here
/usr/lib/gcc/i386-redhat-linux/4.3.0/../../../../include/c++/4.3.0/backward/auto_ptr.h:173:
note: neither the destructor nor the class-specific operator delete will
be called, even if they are declared when the class is defined.
************
I will create another example demonstrating this.
Is there a way to modify the example above to work for non-pod types?