From 7be4e3c89adcce0b98a75431b602341a08d0d5e4 Mon Sep 17 00:00:00 2001 From: Hui Wang Date: Tue, 25 Feb 2020 16:22:35 +0100 Subject: [PATCH] fix stack overflow issue when using initializer_list --- dbms/src/Common/COW.h | 2 +- dbms/src/DataStreams/tests/collapsing_sorted_stream.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/dbms/src/Common/COW.h b/dbms/src/Common/COW.h index b3d23a459ea..d8b50c54368 100644 --- a/dbms/src/Common/COW.h +++ b/dbms/src/Common/COW.h @@ -292,7 +292,7 @@ public: static MutablePtr create(Args &&... args) { return MutablePtr(new Derived(std::forward(args)...)); } template - static MutablePtr create(std::initializer_list && arg) { return create(std::forward>(arg)); } + static MutablePtr create(std::initializer_list && arg) { return MutablePtr(new Derived(std::forward>(arg))); } typename Base::MutablePtr clone() const override { return typename Base::MutablePtr(new Derived(*derived())); } diff --git a/dbms/src/DataStreams/tests/collapsing_sorted_stream.cpp b/dbms/src/DataStreams/tests/collapsing_sorted_stream.cpp index 43205a9e7b5..a34d6a2fbd2 100644 --- a/dbms/src/DataStreams/tests/collapsing_sorted_stream.cpp +++ b/dbms/src/DataStreams/tests/collapsing_sorted_stream.cpp @@ -30,13 +30,13 @@ try ColumnWithTypeAndName column1; column1.name = "Sign"; column1.type = std::make_shared(); - column1.column = ColumnInt8::create({1, -1}); + column1.column = ColumnInt8::create({static_cast(1), static_cast(-1)}); block1.insert(column1); ColumnWithTypeAndName column2; column2.name = "CounterID"; column2.type = std::make_shared(); - column2.column = ColumnUInt32::create({123, 123}); + column2.column = ColumnUInt32::create({static_cast(123), static_cast(123)}); block1.insert(column2); } @@ -46,13 +46,13 @@ try ColumnWithTypeAndName column1; column1.name = "Sign"; column1.type = std::make_shared(); - column1.column = ColumnInt8::create({1, 1}); + column1.column = ColumnInt8::create({static_cast(1), static_cast(1)}); block2.insert(column1); ColumnWithTypeAndName column2; column2.name = "CounterID"; column2.type = std::make_shared(); - column2.column = ColumnUInt32::create({123, 456}); + column2.column = ColumnUInt32::create({static_cast(123), static_cast(456)}); block2.insert(column2); } @@ -76,6 +76,7 @@ try return 0; } + catch (const DB::Exception & e) { std::cerr << e.what() << ", " << e.displayText() << std::endl;