From: SF/projects/mingw n. l. <min...@li...> - 2012-10-26 21:29:10
|
Bugs item #3555870, was opened at 2012-08-09 16:46 Message generated for change (Comment added) made by joshtownzen You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=102435&aid=3555870&group_id=2435 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: MinGW Group: Behaves as Documented Status: Closed Resolution: Invalid Priority: 5 Private: No Submitted By: Josh Townzen (joshtownzen) Assigned to: Nobody/Anonymous (nobody) Summary: commctrl.h macros trigger -Waddress warnings in gcc 4.6.2 Initial Comment: In gcc 4.6.2, the macros ListView_GetItemRect and ListView_GetSubItemRect in commctrl.h test that one of their arguments (the RECT pointer) is non-NULL before using it. When you enable -Waddress (or -Wall) and pass a local RECT variable to either macro, this triggers a warning that the address can never be NULL. OS: Windows 7 32-bit sh-3.1$ gcc -v Using built-in specs. COLLECT_GCC=C:\MinGW\BIN\gcc.exe COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.6.2/lto-wrapper.exe Target: mingw32 Configured with: ../gcc-4.6.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw Thread model: win32 gcc version 4.6.2 (GCC) sh-3.1$ ld -v GNU ld (GNU Binutils) 2.22 Test program: #include <windows.h> #include <commctrl.h> int main() { RECT r; ListView_GetItemRect(NULL, 0, &r, 0); ListView_GetSubItemRect(NULL, 0, 0, 0, &r); return 0; } Compiled via: g++ -o test.exe test.cpp -Waddress -D_WIN32_IE=0x0300 Compiler output: test.cpp: In function 'int main()': test.cpp:7:3: warning: the address of 'r' will always evaluate as 'true' [-Waddress] test.cpp:8:3: warning: the address of 'r' will always evaluate as 'true' [-Waddress] ---------------------------------------------------------------------- Comment By: Josh Townzen (joshtownzen) Date: 2012-10-26 14:29 Message: The problem is that this is the proper way to use either of these two macros; you create a local RECT variable and pass it to the macro to get the result. The caller isn't interested in the implementation details of the macro, and shouldn't be getting a false-positive warning for using it correctly. I was hoping there was a way to rewrite the macros without triggering this warning, though if there is, I haven't been able to find it. ---------------------------------------------------------------------- Comment By: Earnie Boyd (earnie) Date: 2012-10-26 13:56 Message: Yes, the address of a variable will always be non zero. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=102435&aid=3555870&group_id=2435 |