2014-03-05 8:59 GMT+01:00 Yves Bailly <yves.bai...@sescoi.fr>: > > > For what I can see, it seems there's some troubles between QString and > Visual 2013 > initializer-lists implementattion. > > Keeping searching... > >
This is a bug in VS2013 initializer_list that basically makes initializer_list useless for anything but simple types. It's not a problem in QString or Qt for that matter. Here's a simple example: struct RefCount { RefCount(){ ref = new int; *ref = 1; } ~RefCount() { --(*ref); if(*ref == 0) delete ref; } RefCount(const RefCount& r) { ref = r.ref; ++(*ref); } //I ommited operator= and && versions but you can =delete them to make sure int* ref; }; struct Ref { Ref(const RefCount& r) : ref(r) {} RefCount ref; }; int main() { //that's ok std::initializer_list<RefCount> refs1 { RefCount(), RefCount(), RefCount(), RefCount() }; //that's not std::initializer_list<Ref> refs2 { Ref(RefCount()), Ref(RefCount()), Ref(RefCount()), Ref(RefCount()) }; //step into debugger here return 0; } //the debugger shows: (refs1)._First+0 ref=1 (refs1)._First+1 ref=1 (refs1)._First+2 ref=1 (refs1)._First+3 ref=1 (refs2)._First+0 ref.ref=<garbage> (refs2)._First+1 ref.ref=<garbage> (refs2)._First+2 ref.ref=2 (refs2)._First+3 ref.ref=2 There's a copy construction in there so the ref count is briefly 2. It seems it double-deletes the first half of the list and doesn't delete the second (I checked with different number of elements, it's always like that). You can see the same with your class and QString. It's garbage for the first half and QString's atomic counter is 2 for the other half.
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest