https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86135

--- Comment #11 from Sabetay Toros <sabetaytoros at gmail dot com> ---
Here is my test case. The issue is in line 30. Please change the line
commented with direct initilization.

It wont crash.

If you are right list initializers is not usable.

I hope you have an answer.

#include <iostream>using namespace std;#include <vector>#include
<algorithm> #include <limits>#include <math.h>#include
<memory>#include <assert.h>#include <sstream>template <typename T>void
Draw(ostream& os, const T& Entry) {
    os << Entry << endl;}
struct TObject {
    template<typename T>
    TObject(T e) : Self(make_shared<TModel<T>>(move(e))) {}
    friend void Draw(ostream& os, const TObject& Entry) {
        Entry.Self->ModelDraw(os);
    }
    private :
        struct TConcept {
            virtual ~TConcept() = default;
            virtual void ModelDraw(ostream& os) const = 0;
        };
        shared_ptr<const TConcept> Self;
        template<typename T>
        struct TModel final : TConcept {
            TModel(T e) : Data { move(e) } { }
    // It seems the issue is in this line, initiliazer list C++11
version does not work
    //        TModel(T e) : Data ( move(e) ) { }
    // C++98 style is working.
            void ModelDraw(ostream& os) const {
                Draw(os, Data);
            }
            T Data;
        };
};class TMyClass {public :
    string s;
    TMyClass(string e) : s(move(e)) {};
    friend void Draw(ostream& os, const TMyClass& E) {
        os << E.s << endl;
    }};using TDocument = vector<TObject>;void Draw(ostream& os, const
TDocument& vDoc) {
    os << " Document Print ------------------" << endl;
    for(const auto& e: vDoc)
        Draw(os,e);
    os << endl;}using THistory = vector<TDocument>;TDocument&
GetCurrent(THistory& vHstry) {
    return vHstry.back();}void SaveHistory(THistory& vHstry) {
    vHstry.push_back(vHstry.back());}int main(int argc, char** argv) {
    TDocument vDoc;
    THistory vHstry(1);

    GetCurrent(vHstry).emplace_back(1);
    GetCurrent(vHstry).emplace_back(3.2);
    GetCurrent(vHstry).emplace_back(" This is a try");
    GetCurrent(vHstry).emplace_back(" My Class ");
    GetCurrent(vHstry).emplace_back(GetCurrent(vHstry));
    Draw(cout , GetCurrent(vHstry));
    return 0;}



On Wed, Jun 13, 2018 at 11:04 PM, redi at gcc dot gnu.org <
gcc-bugzi...@gcc.gnu.org> wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86135
>
> --- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> ---
> You didn't provide a proper testcase so nobody can possibly explain why
> your
> code crashes.
>
> If it's similar to the code in comment 3 then
> model_t<std::vector<object_t>>
> tries to construct a vector<object_t> from a vector<object_t> using
> list-init
> which chooses the initializer_list constructor because object_t can be
> constructed from vector<object_t>. It's the same bug 85577.
>
> --
> You are receiving this mail because:
> You reported the bug.
>

Reply via email to