Hi all, I was going through some legacy code and came across a behavioral difference between QPair and std::pair:
estan@edison:~$ cat test.cpp #include <QPair> #include <utility> int main(void) { int i = 1; QPair<unsigned, unsigned>{i, i}; std::pair<unsigned, unsigned>{i, i}; return 0; } estan@edison:~$ g++ -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -Wall -fPIC -c test.cpp test.cpp: In function ‘int main()’: test.cpp:6:31: warning: narrowing conversion of ‘i’ from ‘int’ to ‘unsigned int’ [-Wnarrowing] 6 | QPair<unsigned, unsigned>{i, i}; | ^ test.cpp:6:34: warning: narrowing conversion of ‘i’ from ‘int’ to ‘unsigned int’ [-Wnarrowing] 6 | QPair<unsigned, unsigned>{i, i}; | ^ estan@edison:~$ Just curious if anyone know why what difference between QPair and std::pair makes the narrowing conversion warning pop up in the QPair case and not the std::pair case? Note the warning only appears when using aggregate initialization with { }. Using GCC 11.3.0 and Qt 5.15.3. Cheers, Elvis -- Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development