Closed Bug 646336 Opened 13 years ago Closed 13 years ago

js/src/shell/js.cpp fails to compile with -Werror

Categories

(Core :: JavaScript Engine, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: derf, Unassigned)

References

Details

The relevant invocation (default flags, except for the extra -fdiagnostics-show-option I added):

c++ -o js.o -c  -I../../../dist/system_wrappers_js -include /home/derf/sr
c/mozilla/mozilla-central/js/src/config/gcc_hidden.h -DEXPORT_JS_API -DOSTYPE=\"Linux2.6.35\" -DOSARCH=Linux -I/home/derf/src/mozilla/mozilla-central/js/src -I.. -I/home/derf/src/mozilla/mozilla-central/js/src/shell -I. -I../../../dist/include -I../../../dist/include/nsprpub  -I/home/derf/src/mozilla/mozilla-central/objdir-x86_64-unknown-linux-gnu/dist/include/nspr    -fPIC  -fno-rtti -fno-exceptions -Wall -Wpointer-arith -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wcast-align -Wno-invalid-offsetof -Wno-variadic-macros -Werror=return-type -pedantic -Wno-long-long -fno-strict-aliasing -pthread -pipe  -DNDEBUG -DTRIMMED -g -Os -freorder-blocks -fomit-frame-pointer -finline-limit=50 -Werror -fdiagnostics-show-option  -DMOZILLA_CLIENT -include ../js-confdefs.h -MD -MF .deps/js.pp /home/derf/src/mozilla/mozilla-central/js/src/shell/js.cpp
cc1plus: warnings being treated as errors
/home/derf/src/mozilla/mozilla-central/js/src/shell/js.cpp: In function ‘void my_ErrorReporter(JSContext*, const char*, JSErrorReport*)’:
/home/derf/src/mozilla/mozilla-central/js/src/shell/js.cpp:5320:53: error: ignoring return value of ‘size_t fwrite(const void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
/home/derf/src/mozilla/mozilla-central/js/src/nanojit/NativeX64.h: At global scope:
/home/derf/src/mozilla/mozilla-central/js/src/nanojit/NativeX64.h:346:31: error: ‘nanojit::SavedRegs’ defined but not used [-Wunused-variable]
/home/derf/src/mozilla/mozilla-central/js/src/nanojit/NativeX64.h:354:31: error: ‘nanojit::SingleByteStoreRegs’ defined but not used [-Wunused-variable]

Compiler:
gcc (Gentoo 4.5.1 p1.3, pie-0.4.5) 4.5.1
Assignee: nobody → general
Blocks: 609532
Component: Build Config → JavaScript Engine
QA Contact: build-config → general
There's a warn_unused_result attribute on fwrite?  Lame.  Somebody insert a (void) there, or make a JS_UNUSED macro to add it, and let's move on.
Warnings-as-errors is now off again.  See bug 646702 for follow-up.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
(In reply to comment #1)
> There's a warn_unused_result attribute on fwrite?  Lame.  Somebody insert a
> (void) there, or make a JS_UNUSED macro to add it, and let's move on.

warn_unused_result is supposed to be used "whenever ignoring the return value is always a bug", and so casting to void won't help you. gcc even includes a test case to make sure it still warns in this case. The problem is glibc using this attribute in completely inappropriate places.
FWIW, there's a workaround:

  int dummy = fwrite(...)
  (void)dummy;
You need to log in before you can comment on or make changes to this bug.