You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When compiling the following code, em++ does not generate a copy constructor call for the line tested = make_tested();. Instead, it just copies the object's data as if the object was trivially copyable. The copy constructor does get called when increasing the object's size.
#include <cassert>
class Tested;
std::vector<Tested*> objects_that_were_constructed;
class Tested
{
public:
Tested() {
objects_that_were_constructed.push_back(this);
}
Tested(const Tested& other) {
objects_that_were_constructed.push_back(this);
}
Tested& operator=(const Tested& other) {
auto constructor_of_other_was_called =
objects_that_were_constructed.end() != std::find(objects_that_were_constructed.begin(), objects_that_were_constructed.end(), &other);
assert(constructor_of_other_was_called);
// Leaving out the actual assignment code, as it's not relevant
return *this;
}
private:
int state0 = 0;
// Uncommenting the following line makes the test work
// int state1 = 0;
};
Tested make_tested()
{
return Tested();
}
int main() {
Tested tested;
tested = make_tested();
return 0;
}
The text was updated successfully, but these errors were encountered:
I assume this happens even without optimizations? If so, then it's almost certainly an upstream clang issue. I'd recommend verifying it still happens with upstream clang, and if so, filing a bug there.
When compiling the following code, em++ does not generate a copy constructor call for the line
tested = make_tested();
. Instead, it just copies the object's data as if the object was trivially copyable. The copy constructor does get called when increasing the object's size.This happens with:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.37.9
clang version 4.0.0 (https://github.com/kripken/emscripten-fastcomp-clang/ d4b1e0785f1ee15ab78207de4380e82e3407c6ea) (https://github.com/kripken/emscripten-fastcomp/ 09aaa022c31e247bfb7b00882372733e6b27f007) (emscripten 1.37.9 : 1.37.9)
Target: x86_64-apple-darwin15.6.0
The text was updated successfully, but these errors were encountered: