Use aggregate initialization instead of default initialization that l…#389
Use aggregate initialization instead of default initialization that l…#389tanmoy87544 wants to merge 1 commit intoITensor:v3from
Conversation
…eaves simple types undefined
|
Hi, so for this one, is the issue that it could give a compilation error in the future? |
Definitely with C++20, which is my default. But, the same standards violation (moving undefined parts of a struct) is true for C++17, I can check whether the compiler complains in C++17 mode or not. |
OK, checked. It complains when building v3 with g++ (MacPorts gcc10 10.2.0_5) 10.2.0 Compiling itensor/itdata/qdense.cc with optimizations |
…eaves simple types undefined. The problem with the default initialization is it calls value initialization, which leaves simple types undefined. This gives a compilation error when Block(0) is being moved. Changing it to aggregate initialization forces elements to be zero initialized. The time penalty of constructing the arr_ array should be minimal.