#9522 closed bug (fixed)
[userlandFSServer] build failure with Haiku GCC 4
Reported by: | mmadia | Owned by: | nobody |
---|---|---|---|
Priority: | normal | Milestone: | R1 |
Component: | Build System | Version: | R1/Development |
Keywords: | Cc: | ||
Blocked By: | Blocking: | #9559 | |
Platform: | All |
Description
This was briefly mentioned on the mailing list. Here's the ouput of building userlandfs_server for x86_32 GCC 4 from within hrev45285-gcc2h
/generated/x86gcc4> jam -q userlandfs_server ...patience... ...found 7682 target(s)... ...updating 19 target(s)... C++ /generated/x86gcc4/objects/haiku/x86/release/add-ons/kernel/file_systems/userlandfs/server/UserlandFSServer.o /use-the-source/haiku/src/add-ons/kernel/file_systems/userlandfs/server/UserlandFSServer.cpp: In member function 'status_t UserlandFS::UserlandFSServer::_Announce(const char*, port_id)': /use-the-source/haiku/src/add-ons/kernel/file_systems/userlandfs/server/UserlandFSServer.cpp:173:63: error: array subscript is above array bounds [-Werror=array-bounds] cc1plus: all warnings being treated as errors /boot/develop/abi/x86/gcc4/tools/current/bin/gcc -c "/use-the-source/haiku/src/add-ons/kernel/file_systems/userlandfs/server/UserlandFSServer.cpp" -O2 -Wall -Wno-trigraphs -Wno-ctor-dtor-privacy -Woverloaded-virtual -Wpointer-arith -Wcast-align -Wsign-compare -Wno-multichar -pipe -fno-strict-aliasing -nostdinc -Wno-deprecated -march=pentium -D_ZETA_USING_DEPRECATED_API_=1 -D_ZETA_TS_FIND_DIR_=1 -Werror -Wno-error=uninitialized -Wno-unused-but-set-variable -DUSER=1 -DDEBUG_APP=\"userlandfs_server\" -DBUILDING_USERLAND_FS_SERVER=1 -D__HAIKU__ -DHAIKU_DISTRO_COMPATIBILITY_DEFAULT -D__INTEL__ -DARCH_x86 -DBOOT_ARCHIVE_IMAGE_OFFSET=300 -DB_USE_BUILTIN_ATOMIC_FUNCTIONS -DHAIKU_INCLUDE_PATENTED_CODE=0 -DHAIKU_TARGET_PLATFORM_HAIKU -iquote /use-the-source/haiku/build/user_config_headers -iquote /use-the-source/haiku/build/config_headers -iquote /use-the-source/haiku/src/add-ons/kernel/file_systems/userlandfs/server -iquote /generated/x86gcc4/objects/common/add-ons/kernel/file_systems/userlandfs/server -iquote /generated/x86gcc4/objects/haiku_host/x86/common/add-ons/kernel/file_systems/userlandfs/server -iquote /generated/x86gcc4/objects/haiku/x86/common/add-ons/kernel/file_systems/userlandfs/server -iquote /use-the-source/haiku/src/add-ons/kernel/file_systems/userlandfs/private -iquote /use-the-source/haiku/src/add-ons/kernel/file_systems/userlandfs/shared -iquote /use-the-source/haiku/headers/private/userlandfs/private -iquote /use-the-source/haiku/headers/private/userlandfs/shared -I /use-the-source/haiku/headers/private/userlandfs -I /use-the-source/haiku/headers/private/. -I /use-the-source/haiku/headers/private/kernel -I /use-the-source/haiku/headers/private/libroot -I /use-the-source/haiku/headers/private/shared -I /use-the-source/haiku/headers/private/kernel/boot/platform/bios_ia32 -I /use-the-source/haiku/headers/private/kernel/arch/x86 -I /generated/x86gcc4/objects/haiku/x86/common/system/kernel -I /use-the-source/haiku/headers/private/. -I /use-the-source/haiku/headers/private/system -I /use-the-source/haiku/headers/private/system/arch/x86 -I /use-the-source/haiku/headers/private/libroot -I /use-the-source/haiku/headers/private/shared -I /boot/develop/abi/x86/gcc4/tools/gcc-4.6.3-haiku-121101/lib/gcc/i586-pc-haiku/4.6.3/../../../../include/c++/4.6.3 -I /boot/develop/abi/x86/gcc4/tools/gcc-4.6.3-haiku-121101/lib/gcc/i586-pc-haiku/4.6.3/../../../../include/c++/4.6.3/i586-pc-haiku -I /boot/develop/abi/x86/gcc4/tools/gcc-4.6.3-haiku-121101/lib/gcc/i586-pc-haiku/4.6.3/../../../../include/c++/4.6.3/backward -I /boot/develop/abi/x86/gcc4/tools/gcc-4.6.3-haiku-121101/lib/gcc/i586-pc-haiku/4.6.3/../../../../include/c++/4.6.3/ext -I /boot/develop/abi/x86/gcc4/tools/gcc-4.6.3-haiku-121101/lib/gcc/i586-pc-haiku/4.6.3/include -I /boot/develop/abi/x86/gcc4/tools/gcc-4.6.3-haiku-121101/lib/gcc/i586-pc-haiku/4.6.3/include-fixed -I /use-the-source/haiku/headers -I /use-the-source/haiku/headers/posix -I /use-the-source/haiku/headers/glibc -I /use-the-source/haiku/headers/os -I /use-the-source/haiku/headers/os/add-ons -I /use-the-source/haiku/headers/os/add-ons/file_system -I /use-the-source/haiku/headers/os/add-ons/graphics -I /use-the-source/haiku/headers/os/add-ons/input_server -I /use-the-source/haiku/headers/os/add-ons/registrar -I /use-the-source/haiku/headers/os/add-ons/screen_saver -I /use-the-source/haiku/headers/os/add-ons/tracker -I /use-the-source/haiku/headers/os/app -I /use-the-source/haiku/headers/os/device -I /use-the-source/haiku/headers/os/drivers -I /use-the-source/haiku/headers/os/game -I /use-the-source/haiku/headers/os/interface -I /use-the-source/haiku/headers/os/kernel -I /use-the-source/haiku/headers/os/locale -I /use-the-source/haiku/headers/os/media -I /use-the-source/haiku/headers/os/mail -I /use-the-source/haiku/headers/os/midi -I /use-the-source/haiku/headers/os/midi2 -I /use-the-source/haiku/headers/os/net -I /use-the-source/haiku/headers/os/opengl -I /use-the-source/haiku/headers/os/storage -I /use-the-source/haiku/headers/os/support -I /use-the-source/haiku/headers/os/translation -I /use-the-source/haiku/headers/private/. -o "/generated/x86gcc4/objects/haiku/x86/release/add-ons/kernel/file_systems/userlandfs/server/UserlandFSServer.o" ; ...failed C++ /generated/x86gcc4/objects/haiku/x86/release/add-ons/kernel/file_systems/userlandfs/server/UserlandFSServer.o ... BUILD FAILURE: ...failed updating 1 target(s)... ...skipped 1 target(s)... /generated/x86gcc4>
Attachments (1)
Change History (16)
comment:1 by , 12 years ago
Component: | Add-Ons → File Systems/UserlandFS |
---|---|
Owner: | changed from | to
Status: | new → assigned |
follow-up: 3 comment:2 by , 12 years ago
Owner: | changed from | to
---|
comment:3 by , 12 years ago
Replying to bonefish:
Disable the useless warnings?
That was my thought since I don't see what is wrong with this code. It seems silly having to work around a compiler being stupid.
follow-up: 6 comment:5 by , 12 years ago
I don't get this. Why are we indexing info->portInfos
? It is of class Address
which doesn't define operator []
and isn't an array.
comment:6 by , 12 years ago
Replying to mounty:
I don't get this. Why are we indexing
info->portInfos
? It is of classAddress
which doesn't defineoperator []
and isn't an array.
Actually it is, c.f. http://haiku.it.su.se:8180/source/xref/headers/private/userlandfs/private/UserlandFSDefs.h#fs_init_info
gcc apparently gets confused by the use of the flexible array member in this instance. The fix would simply be to disable that particular warning since it's yielding false positives in a number of situations (and was only introduced in the latest version of gcc).
comment:7 by , 12 years ago
+1 for explicitly and globally disabling -Warray-bounds
. Let Coverity do the static analysis and GCC do the compiling. Moreover, since it is not enabled by default when not compiling under Haiku buildbot won't catch any future build failures and it would become a recurring problem.
However, if we want to be very strict the standard does not allow arrays of length 0 (C++03 8.3.4/1).
comment:8 by , 12 years ago
Sorry; I was looking at the wrong declaration (obviously).
It seems to me that rather than omit a useful compiler warning (which has found real bugs; see #9486) we add an inline function to spoof the compiler in this rare case:
struct fs_init_info { FSCapabilities capabilities; client_fs_type clientFSType; int32 portInfoCount; Port::Info portInfos[0]; Port::Info * portInformation () { return portInfos; } };
or maybe, to satisfy C++03 8.3.4/1 as mentioned above:
struct fs_init_info { FSCapabilities capabilities; client_fs_type clientFSType; int32 portInfoCount; class { } infoAlign; Port::Info * portInfos () { return reinterpret_cast<Port::Info *>(&infoAlign); } };
I do not see the point in ignoring information that the compiler is offering.
comment:9 by , 12 years ago
Out of 3 build failures caused by -Warray-bounds
only one was not a false positive and it was already found by Coverity anyway.
Value range propagation is a simple static analysis which is performed only in translation unit scope. Therefore it never has complete information. It is not a problem when performing an optimization (although it also has caused problems by optimizing out too much, but that was very specific case). It is a problem when GCC tries to be a static analysis tool too hard and in a result warnings are reported despite the fact the code is correct.
It is really necessary to has complete information about source code to reliably perform such analysis and that is what Coverity is for.
follow-up: 11 comment:10 by , 12 years ago
OK, we've all made our points and I accept that the consensus is to remove the warning. I disagree, but the most important thing for me is to be able to build Haiku again.
comment:11 by , 12 years ago
Replying to mounty:
OK, we've all made our points and I accept that the consensus is to remove the warning. I disagree, but the most important thing for me is to be able to build Haiku again.
If you're solely concerned about whether you can compile Haiku again, it should be a trivial temporary fix to just disable the "warnings-as-errors" for that particular subdirectory. I'll attach a patch that should do it for you.
by , 12 years ago
Attachment: | userlandfs_disable_werror.diff added |
---|
Should disable werror on userlandfs
follow-ups: 13 15 comment:12 by , 12 years ago
Great, thanks! Building again. Presumably this change will be committed to the repository at some stage?
The new Haiku builds alright but goes to KDL on boot. Hmm. Anyway, that is irrelevant to this ticket.
follow-up: 14 comment:13 by , 12 years ago
Replying to mounty:
Great, thanks! Building again. Presumably this change will be committed to the repository at some stage?
No, the warning should be disabled instead, i.e. -Wno-array-bounds
needs to be added to the compiler flags instead.
comment:14 by , 12 years ago
Component: | File Systems/UserlandFS → Build System |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Disable the useless warnings?