Activity log for bug #305176

Date Who What changed Old value New value Message
2008-12-04 14:59:10 tz bug added bug
2008-12-04 15:09:37 Matthias Klose bug assigned to glibc (Ubuntu)
2008-12-04 15:09:54 Matthias Klose bug assigned to glibc
2008-12-04 15:10:10 Matthias Klose gcc-defaults: status New Triaged
2008-12-04 15:10:10 Matthias Klose gcc-defaults: importance Undecided Low
2008-12-04 15:10:10 Matthias Klose gcc-defaults: statusexplanation
2008-12-04 15:10:38 Matthias Klose glibc: status New Triaged
2008-12-04 15:10:38 Matthias Klose glibc: importance Undecided Low
2008-12-04 15:10:38 Matthias Klose glibc: statusexplanation
2008-12-04 15:11:13 Matthias Klose title GCC 4.3 in Intrepid has pages of new warnings can't disable __attribute__((warn_unused_result))
2008-12-04 15:11:51 Matthias Klose title can't disable __attribute__((warn_unused_result)) [PR25509] can't disable __attribute__((warn_unused_result))
2008-12-04 15:19:12 Bug Watch Updater glibc: status Unknown Confirmed
2009-01-21 14:12:23 Colin Watson description Binary package hint: gcc This might be in one of the libs, but the problem is fundamentally in gcc. There is a recent attribute (warn_unused_result) that has been applied to nearly every function that isn't declared a void. This includes things like write and fwrite (and even fread and read). So many programs that compiled cleanly now spew forth pages of errors. THERE IS NO WAY TO DISABLE THIS WARNING. Either from CFLAGS or with anything simple like a cast. With the pages of new warnings, it is hard to find real errors or warnings about significant things. In most cases the ignoring of the return value is intentional - in the case of the read, it is for an echo which I know will occur from a device - the write will fail if the device detaches, but I need to wait for the echo before the close - which I would do anyway if the read failed. For most writes, they are also "fire and forget" and an actual problem will be caught at some point - having a chain of 20 writes (including logging and stderr) - it is unlikely that just one in the middle will fail. Or they are clean shutdown that an exit(x) would handle less gracefully. Others would only error on SIG_ARMAGEDDON or SIG_MAGIC cases where a cosmic ray has flipped a bit in ram somewhere or the CPU is overheating or some other problem which is both unlikely and there is no good way to handle it. There is also no pedantic_warn... or Wall_warn variants where this might be appropriate for these middle cases - I do turn them on occasionally to verify the code. (Things like signed-unsigned conversions or comparison are in this class - often I know the range is limited so the code will work). And the warning is appropriate for almost every call that does return significant information. One that doesn't seem to have it is printf, but it seems neither does fprintf, and it is just a formatter over fwrite which I think does have this attribute (and will succeed - to the buffer, fflush might expose an error condition). Since there are lots of libraries with lots of different authors (and I think the syscalls which would include write are part of gcc), the easier fix is to lower this warning below default (to -Wall or -pedantic), or at least provide a -no-warn-unused-result option. For completeness a secondary attribute equivalent to warn_unused_result that only prints a warning when -Wall or -pedantic is used can be added to GCC so we could have the best of both worlds. Or run the body of ubuntu universe or the 18k debian packages and see which functions are commonly affected and quiet the warnings on very common cases in the originating library header file (remove or modify the attribute), e.g. write, and I think fwrite, but there may be many others I don't know about where ignoring a return value is common practice and is not bad technique. Binary package hint: gcc This might be in one of the libs, but the problem is fundamentally in gcc. There is a recent attribute (warn_unused_result) that has been applied to nearly every function that isn't declared a void. This includes things like write and fwrite (and even fread and read). So many programs that compiled cleanly now spew forth pages of errors. THERE IS NO WAY TO DISABLE THIS WARNING. Either from CFLAGS or with anything simple like a cast. [This is not the case; -U_FORTIFY_SOURCE disables it, as does if (write(...)) {}, the latter of which could easily be turned into a macro if desired. -cjwatson] With the pages of new warnings, it is hard to find real errors or warnings about significant things. In most cases the ignoring of the return value is intentional - in the case of the read, it is for an echo which I know will occur from a device - the write will fail if the device detaches, but I need to wait for the echo before the close - which I would do anyway if the read failed. For most writes, they are also "fire and forget" and an actual problem will be caught at some point - having a chain of 20 writes (including logging and stderr) - it is unlikely that just one in the middle will fail. Or they are clean shutdown that an exit(x) would handle less gracefully. Others would only error on SIG_ARMAGEDDON or SIG_MAGIC cases where a cosmic ray has flipped a bit in ram somewhere or the CPU is overheating or some other problem which is both unlikely and there is no good way to handle it. There is also no pedantic_warn... or Wall_warn variants where this might be appropriate for these middle cases - I do turn them on occasionally to verify the code. (Things like signed-unsigned conversions or comparison are in this class - often I know the range is limited so the code will work). And the warning is appropriate for almost every call that does return significant information. One that doesn't seem to have it is printf, but it seems neither does fprintf, and it is just a formatter over fwrite which I think does have this attribute (and will succeed - to the buffer, fflush might expose an error condition). Since there are lots of libraries with lots of different authors (and I think the syscalls which would include write are part of gcc), the easier fix is to lower this warning below default (to -Wall or -pedantic), or at least provide a -no-warn-unused-result option. For completeness a secondary attribute equivalent to warn_unused_result that only prints a warning when -Wall or -pedantic is used can be added to GCC so we could have the best of both worlds. Or run the body of ubuntu universe or the 18k debian packages and see which functions are commonly affected and quiet the warnings on very common cases in the originating library header file (remove or modify the attribute), e.g. write, and I think fwrite, but there may be many others I don't know about where ignoring a return value is common practice and is not bad technique.
2009-07-11 04:27:05 Bug Watch Updater glibc: status Confirmed Fix Released
2009-07-30 17:51:24 Launchpad Janitor branch linked lp:debian/sid/gnat-4.4
2011-01-25 23:17:17 Bug Watch Updater glibc: importance Unknown Medium
2011-01-25 23:17:32 Bug Watch Updater bug watch added http://sourceware.org/bugzilla/show_bug.cgi?id=11959
2015-03-14 19:58:57 Adam Conrad gcc-defaults (Ubuntu): status Triaged Fix Released
2015-03-14 19:58:59 Adam Conrad glibc (Ubuntu): status Triaged Fix Released
2018-08-18 07:48:35 Bug Watch Updater bug watch added https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425