Closed Bug 377754 Opened 18 years ago Closed 18 years ago

JS_CLASS_TRACE does not compiles with g++

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: igor, Assigned: igor)

References

Details

(Keywords: regression)

Attachments

(1 file, 3 obsolete files)

The bug 375270 introduced JS_CLASS_TRACE to convert JSTraceOp to JSMarkOp when initializing JSClass.mark member. The current implementation under GCC tries to be type-safe using __builtin_types_compatible_p to check the proper type of the method. But according to http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Other-Builtins.html#Other-Builtins __builtin_types_compatible_p is only available in C, not C++.

Thus the macro must be fixed to use __builtin_types_compatible_p only with C, not C++.
Attached patch Fix v1 (obsolete) (deleted) — Splinter Review
A trivial fix. 

The macro is still useful as it allows, for example, to add a preprocessor define that would change JSMarkOp to JSTraceOp to verify the code.
Attachment #261782 - Flags: review?(brendan)
Severity: enhancement → normal
Attached patch Fix v2 (obsolete) (deleted) — Splinter Review
This the previous patch plus fix for the misspelling that was pointed out in bug 375270 comment 48 but which I forgot to address in the final committed patch.
Attachment #261782 - Attachment is obsolete: true
Attachment #261785 - Flags: review?(brendan)
Attachment #261782 - Flags: review?(brendan)
Comment on attachment 261785 [details] [diff] [review]
Fix v2

>Index: jspubtd.h
>+    (__builtin_types_compatible_p(JSTraceOp, __typeof(&(method)))             \
>      ? (JSMarkOp)(method)                                                     \
>      : JS_WrongTypeForClassTacer)
> 
> extern JSMarkOp JS_WrongTypeForClassTacer;

Could you fix "Tacer" while you're here, particularly as it's something which uses the public naming scheme?  (I have no idea whether it's intended for public use, but either way the spelling error's bad.)

Also, you almost never need a new review for a spelling fix (well-established API names being the only exception that springs to mind, and this certainly isn't), so don't bother asking for one and just fix it on checkin.  :-)
Attached patch Fix v3 (obsolete) (deleted) — Splinter Review
This v2 + rename to fix bad spelling in a variable name.
Attachment #261785 - Attachment is obsolete: true
Attachment #261800 - Flags: review?(brendan)
Attachment #261785 - Flags: review?(brendan)
Comment on attachment 261800 [details] [diff] [review]
Fix v3

Might be better to use js_ instead of JS_ for the undefined function here.

/be
Attachment #261800 - Flags: review?(brendan) → review+
Attached patch Fix v4 (deleted) — Splinter Review
Patch to commit with JS_WrongTypeForClassTracer -> js_WrongTypeForClassTracer rename.
Attachment #261800 - Attachment is obsolete: true
Attachment #261844 - Flags: review+
I committed the patch from comment 6 to the trunk:

Checking in jsapi.h;
/cvsroot/mozilla/js/src/jsapi.h,v  <--  jsapi.h
new revision: 3.144; previous revision: 3.143
done
Checking in jspubtd.h;
/cvsroot/mozilla/js/src/jspubtd.h,v  <--  jspubtd.h
new revision: 3.79; previous revision: 3.78
done
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Flags: in-testsuite-
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: