Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUILD] warning fix: new does not have an alignment parameter #1478

Merged
merged 3 commits into from
Jul 27, 2018

Conversation

joyalbin
Copy link
Contributor

The below warning is shown with environment GCC 7.2 and -std=c++11

This PR will fix the below warnings tvm/vta/src/sim/sim_driver.cc: In constructor _vta::sim::DRAM::Page::Page(size_t, size_t)_: tvm/vta/src/sim/sim_driver.cc:196:33: warning: _new_ of type _vta::sim::DRAM::Page::DType {aka std::aligned_storage<4096, 256> ::type}_ with extended alignment 256 [-Waligned-new=] data = new DType[num_pages]; ^ tvm/vta/src/sim/sim_driver.cc:196:33: note: uses _void* operator new [](std::size_t)_, which does not have an alignment parameter tvm/vta/src/sim/sim_driver.cc:196:33: note: use _-faligned-new_ to enable C++17 over-aligned new support tvm/vta/src/sim/sim_driver.cc: In instantiation of _vta::sim::SRAM<kBits, kLane, kMaxNumElem>::SRAM() [with int kBits = 8; int kLane = 256; int kMaxNumElem = 1024]_: tvm/vta/src/sim/sim_driver.cc:345:12: required from here tvm/vta/src/sim/sim_driver.cc:226:13: warning: _new_ of type _vta::sim::SRAM<8, 256, 1024>::DType {aka std::aligned_storage<25 6, 256>::type}_ with extended alignment 256 [-Waligned-new=] data_ = new DType[kMaxNumElem]; ^~~~~~~~~~~~~~~~~~~~~~ tvm/vta/src/sim/sim_driver.cc:226:13: note: uses _void* operator new [](std::size_t)_, which does not have an alignment parameter tvm/vta/src/sim/sim_driver.cc:226:13: note: use _-faligned-new_ to enable C++17 over-aligned new support tvm/vta/src/sim/sim_driver.cc: In instantiation of _vta::sim::SRAM<kBits, kLane, kMaxNumElem>::SRAM() [with int kBits = 32; in t kLane = 16; int kMaxNumElem = 2048]_: tvm/vta/src/sim/sim_driver.cc:345:12: required from here tvm/vta/src/sim/sim_driver.cc:226:13: warning: _new_ of type _vta::sim::SRAM<32, 16, 2048>::DType {aka std::aligned_storage<64 , 64>::type}_ with extended alignment 64 [-Waligned-new=] tvm/vta/src/sim/sim_driver.cc:226:13: note: uses _void* operator new [](std::size_t)_, which does not have an alignment parameter tvm/vta/src/sim/sim_driver.cc:226:13: note: use _-faligned-new_ to enable C++17 over-aligned new support

This PR will avoid the issue
Reference: https://github.com/google/flatbuffers/pull/4621/files

@tqchen
Copy link
Member

tqchen commented Jul 24, 2018

please also check if the compiler itself is g++ as we can also use clang

CMakeLists.txt Outdated
@@ -78,6 +78,9 @@ else(MSVC)
check_cxx_compiler_flag("-std=c++11" SUPPORT_CXX11)
set(CMAKE_C_FLAGS "-O2 -Wall -fPIC ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-O2 -Wall -fPIC -std=c++11 ${CMAKE_CXX_FLAGS}")
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to confirm if compiler is g++, otherwise the rule is not correct fo clang

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tqchen I have used 'g++' compiler (cc1plus) and warnings are seen.

I verified build with 'clang' and not seen the these warnings.
Shall I add check for 'g++' here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, please only trigger this flag when compiler is g++

@tqchen tqchen added the status: need update need update based on feedbacks label Jul 25, 2018
@tqchen tqchen merged commit aa23952 into apache:master Jul 27, 2018
@tqchen
Copy link
Member

tqchen commented Jul 27, 2018

Thanks @joyalbin ! This is now merged

@tqchen tqchen added status: accepted and removed status: need update need update based on feedbacks labels Jul 27, 2018
tqchen pushed a commit to tqchen/tvm that referenced this pull request Aug 4, 2018
sergei-mironov pushed a commit to sergei-mironov/tvm that referenced this pull request Aug 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants