Reviewers: dcarney,
Message:
Please have a look.
(Following crrev.com/267393002, this now compiles just fine in Chromium +
blink.)
Description:
Prevent calls to ReturnValue::Set with pointer-valued types.
Currently, this code will compile:
SomePointer* p = ...;
ReturnValue r = ...;
r.Set(p);
What happens is that ReturnValue::Set has no pointer-ish overloads, but
a bool one, and hence C++ will convert the pointer to a bool and use
the Set(bool) overload. In other words, the example above is equivalent
to: r.Set(p ? true : false); Which probably isn't what the author had
in mind. This change adds a Set(void*) overload whose body forces a
compile error, to prevent this from happening inadvertently. The only
use of this indeed turned out to be an error.
(Wait for issue 364025 before submitting.)
BUG=
Please review this at https://codereview.chromium.org/240013004/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+9, -0 lines):
M include/v8.h
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index
4d99d151522b98b22d8d10fc2ec5e2f0b77e7798..ceb57c0abd3cafc1d228da2d8efbd72ee324d02f
100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -2458,6 +2458,9 @@ class ReturnValue {
// Convenience getter for Isolate
V8_INLINE Isolate* GetIsolate();
+ // Pointer setter: Uncompilable to prevent inadvertent misuse.
+ void Set(void* whatever);
+
private:
template<class F> friend class ReturnValue;
template<class F> friend class FunctionCallbackInfo;
@@ -5981,6 +5984,12 @@ Isolate* ReturnValue<T>::GetIsolate() {
}
template<typename T>
+void ReturnValue<T>::Set(void* whatever) {
+ // Uncompilable to prevent inadvertent misuse.
+ TYPE_CHECK(void*, Primitive);
+}
+
+template<typename T>
internal::Object* ReturnValue<T>::GetDefaultValue() {
// Default value is always the pointer below value_ on the stack.
return value_[-1];
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.