4 ms·
A similar defect that was "fixed" breaking backward compatibility was the resolution of initializer_list constructors of recursive types: T(initializer_list<
by ot 10y ago
A similar defect that was "fixed" breaking backward compatibility was the resolution of initializer_list constructors of recursive types:
T(initializer_list<T>);
Before, if you did
T element;
T list = {element};
the second initialization would be dispatched to the initializer_list constructor; after the fix (for GCC, after 4.9) it would call the copy constructor. See http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1467 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html... .
For us, this changed the semantics of folly::dynamic, which used the initializer_list constructor to construct lists:
dynamic element = "hello";
dynamic list = {element}; // ["hello"] before, "hello" after
We had to deprecate the initializer_list constructor and fix all the occurrences (https://github.com/facebook/folly/commit/07dc3ce5923b2d761ca9fd7cd53ee890a4ad839d https://github.com/facebook/folly/commit/07dc3ce5923b2d761ca..., https://github.com/facebook/folly/commit/d458b0a14486b9d80d5644c7b4de60640c891df1 https://github.com/facebook/folly/commit/d458b0a14486b9d80d5...).
- gpderetta 10y agoAnd that fix is still far from fixing the language. I had tought that deprecating brace elision for initializer_list and always requiring double braces would be a workable, although backward incompatible fix, but it still cause issues. There was a recent thread on the topic on std-discussion recently. [hi ot, long time no see]
- ot 10y agoYeah, double-braces was also my first guess but found out that Clang and GCC handled it differently (!) so I didn't even try to understand what the std mandates. [hey! :)]