Closed
Bug 921586
Opened 11 years ago
Closed 11 years ago
'may be used uninitialized' warnings in StructuredClone.cpp
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
mozilla28
People
(Reporter: jimb, Assigned: jimb)
Details
(Whiteboard: [qa-])
Attachments
(2 files)
3.08 KB,
patch
|
n.nethercote
:
review+
|
Details | Diff | Splinter Review |
3.19 MB,
text/plain
|
Details |
Specifically, it seems that G++ 4.8.1 is unable to tell that the call to
AutoCompartment::~AutoCompartment is protected by the Maybe::constructed
flag.
The "solution" is not to use Maybe here; although Debugger.cpp uses
Maybe<AutoCompartment> everywhere, it gets away with it because it always
actually constructs the Maybe(?!?).
It's a shame to let the compiler's stupidity shape the code, but that
particular warning is valuable elsewhere, so I feel that we shouldn't just
disable the warning.
In file included from /home/jimb/moz/dbg/js/src/jsobjinlines.h:20:0,
from /home/jimb/moz/dbg/js/src/vm/StructuredClone.cpp:44:
/home/jimb/moz/dbg/js/src/jscompartmentinlines.h: In function ‘bool JS_StructuredClone(JSContext*, JS::Value, JS::Value*, const JSStructuredCloneCallbacks*, void*)’:
/home/jimb/moz/dbg/js/src/jscompartmentinlines.h:45:35: warning: ‘ac.js::AutoCompartment::origin_’ may be used uninitialized in this function [-Wmaybe-uninitialized]
cx_->leaveCompartment(origin_);
^
/home/jimb/moz/dbg/js/src/vm/StructuredClone.cpp:1521:41: note: ‘ac.js::AutoCompartment::origin_’ was declared here
mozilla::Maybe<AutoCompartment> ac;
^
In file included from /home/jimb/moz/dbg/js/src/jsobjinlines.h:20:0,
from /home/jimb/moz/dbg/js/src/vm/StructuredClone.cpp:44:
/home/jimb/moz/dbg/js/src/jscompartmentinlines.h:45:35: warning: ‘ac.js::AutoCompartment::cx_’ may be used uninitialized in this function [-Wmaybe-uninitialized]
cx_->leaveCompartment(origin_);
^
/home/jimb/moz/dbg/js/src/vm/StructuredClone.cpp:1521:41: note: ‘ac.js::AutoCompartment::cx_’ was declared here
mozilla::Maybe<AutoCompartment> ac;
^
Attachment #811311 -
Flags: review?(mike)
Comment 1•11 years ago
|
||
Interesting, I cannot reproduce the warning. I'm using gcc 4.8.1 20130725 (the default one on Arch) with a default build configuration. Which version are you using?
Updated•11 years ago
|
Flags: needinfo?(jimb)
Assignee | ||
Comment 2•11 years ago
|
||
I'm using g++ (GCC) 4.8.1 20130603 (Red Hat 4.8.1-1). I don't get the warning on shell-only builds, but I do when I build as part of the whole Firefox tree, with the following .mozconfig:
ac_add_options --enable-debug='-g3 -O1'
ac_add_options --disable-optimize
ac_add_options --enable-trace-malloc
It seems like this is #defining MOZ_GLUE_IN_PROGRAM on the command line and not MFBT_IMPL. Here's the whole command:
c++ -o StructuredClone.o -c -I./../../dist/system_wrappers_js -include /home/jimb/moz/dbg/js/src/config/gcc_hidden.h -DENABLE_PARALLEL_JS -DENABLE_BINARYDATA -DMOZ_GLUE_IN_PROGRAM -DNO_NSPR_10_SUPPORT -DEXPORT_JS_API -DJS_HAS_CTYPES -DDLL_PREFIX=\"lib\" -DDLL_SUFFIX=\".so\" -DUSE_ZLIB -Ictypes/libffi/include -I/home/jimb/moz/dbg/js/src/../../mfbt/double-conversion -I/home/jimb/moz/dbg/js/src/../../intl/icu/source/common -I/home/jimb/moz/dbg/js/src/../../intl/icu/source/i18n -I/home/jimb/moz/dbg/js/src -I. -I./../../dist/include -I/home/jimb/moz/dbg/obj-bug/dist/include/nspr -I/home/jimb/moz/dbg/js/src -fPIC -DMOZILLA_CLIENT -include ./js-confdefs.h -MD -MP -MF .deps/StructuredClone.o.pp -Wall -Wpointer-arith -Woverloaded-virtual -Werror=return-type -Wtype-limits -Wempty-body -Werror=conversion-null -Wsign-compare -Wno-invalid-offsetof -Wcast-align -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -std=gnu++0x -pthread -pipe -DDEBUG -D_DEBUG -DTRACING -g3 -O1 -fno-omit-frame-pointer -DUSE_SYSTEM_MALLOC=1 -DENABLE_ASSEMBLER=1 -DENABLE_JIT=1 /home/jimb/moz/dbg/js/src/vm/StructuredClone.cpp
Flags: needinfo?(jimb)
Assignee | ||
Comment 3•11 years ago
|
||
This attachment is the output from preprocessing StructuredClone.cpp, so it doesn't depend on any header files or preprocessor macro definitions. You can compile it and see the warning with the command:
c++ -o StructuredClone.o -c -fPIC -Wall -Wpointer-arith -Woverloaded-virtual -Werror=return-type -Wtype-limits -Wempty-body -Werror=conversion-null -Wsign-compare -Wno-invalid-offsetof -Wcast-align -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -std=gnu++0x -pthread -pipe -g3 -O1 -fno-omit-frame-pointer StructuredClone.ii
Assignee | ||
Comment 4•11 years ago
|
||
Comment on attachment 811311 [details] [diff] [review]
Avoid 'may be used uninitialized' warnings in StructuredClone.cpp.
Mike isn't available to look at this; Waldo, would you be willing to check it out?
Attachment #811311 -
Flags: review?(mike) → review?(jwalden+bmo)
Comment 5•11 years ago
|
||
Comment on attachment 811311 [details] [diff] [review]
Avoid 'may be used uninitialized' warnings in StructuredClone.cpp.
Review of attachment 811311 [details] [diff] [review]:
-----------------------------------------------------------------
Stealing -- looks fine to me.
Attachment #811311 -
Flags: review?(jwalden+bmo) → review+
Assignee | ||
Comment 6•11 years ago
|
||
Flags: in-testsuite-
Target Milestone: --- → mozilla28
Comment 7•11 years ago
|
||
Assignee: nobody → jimb
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Updated•11 years ago
|
Whiteboard: [qa-]
You need to log in
before you can comment on or make changes to this bug.
Description
•