Closed Bug 393364 Opened 17 years ago Closed 17 years ago

mozilla-central: build fails in js/src, "uninitialized const 'DoubleHashOps'" (C/C++ incompatibility)

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
major

Tracking

()

RESOLVED FIXED

People

(Reporter: jorendorff, Assigned: jorendorff)

Details

Attachments

(1 file, 1 obsolete file)

Attached patch v1 (obsolete) — Splinter Review
In trunk, this is mostly harmless: it means you can't build JS with a C++ compiler.  In mozilla-central, it breaks the build.  It should be fixed in trunk, though, and merged downstream.

cvs-trunk-mirror/js/src$ make CC=g++ -f Makefile.ref
...
g++ -o Darwin_DBG.OBJ/jsatom.o -c -Wall -Wno-format -g -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DDARWIN -DX86_LINUX  -DDEBUG -DDEBUG_jason -DEDITLINE -IDarwin_DBG.OBJ  jsatom.c
jsatom.c:244: error: uninitialized const 'DoubleHashOps'
jsatom.c:245: error: uninitialized const 'StringHashOps'
jsatom.c:317: error: redefinition of 'const JSDHashTableOps DoubleHashOps'
jsatom.c:244: error: 'const JSDHashTableOps DoubleHashOps' previously declared here
jsatom.c:328: error: redefinition of 'const JSDHashTableOps StringHashOps'
jsatom.c:245: error: 'const JSDHashTableOps StringHashOps' previously declared here
make[1]: *** [Darwin_DBG.OBJ/jsatom.o] Error 1
make[1]: Leaving directory `/Users/jason/dev/am/cvs-trunk-mirror/js/src'
make: *** [all] Error 2

I think C++ forbids this as a consequence of the One-Definition Rule.  In any case, rearranging things a little seems to appease the compiler.
Attachment #277869 - Flags: review?(igor)
Attachment #277869 - Flags: approval1.9?
Comment on attachment 277869 [details] [diff] [review]
v1

>-static const JSDHashTableOps DoubleHashOps;
>-static const JSDHashTableOps StringHashOps;
>+JS_STATIC_DLL_CALLBACK(JSDHashNumber)
>+HashDouble(JSDHashTable *table, const void *key);
>+
>+JS_STATIC_DLL_CALLBACK(JSBool)
>+MatchDouble(JSDHashTable *table, const JSDHashEntryHdr *hdr, const void *key);
>+
>+static const JSDHashTableOps DoubleHashOps = {
>+    JS_DHashAllocTable,
>+    JS_DHashFreeTable,
>+    HashDouble,
>+    MatchDouble,
>+    JS_DHashMoveEntryStub,
>+    JS_DHashClearEntryStub,
>+    JS_DHashFinalizeStub,
>+    NULL
>+};
>+
>+JS_STATIC_DLL_CALLBACK(JSDHashNumber)
>+HashString(JSDHashTable *table, const void *key);
>+
>+JS_STATIC_DLL_CALLBACK(JSBool)
>+MatchString(JSDHashTable *table, const JSDHashEntryHdr *hdr, const void *key);

Nit: move HashString and MatchString before DoubleHashOps to group similar-purpose code together. r+ with that fixed.
Attached patch v1aSplinter Review
Sorry, knee-jerk OOP on my part.  :)
Assignee: general → jorendorff
Attachment #277869 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #277900 - Flags: review?(igor)
Attachment #277869 - Flags: review?(igor)
Attachment #277869 - Flags: approval1.9?
Attachment #277900 - Flags: approval1.9?
Igor, I'm not a CVS committer; could you please check this in (presuming it's approval1.9+)?

Thanks for the speedy review.
Comment on attachment 277900 [details] [diff] [review]
v1a

Pre-approving, letting Igor mark and land. Thanks,

/be
Attachment #277900 - Flags: approval1.9? → approval1.9+
Attachment #277900 - Flags: review?(igor) → review+
I checked in the patch from comment 2 to the trunk:

http://bonsai.mozilla.org/cvsquery.cgi?module=PhoenixTinderbox&branch=HEAD&cvsroot=%2Fcvsroot&date=explicit&mindate=1187895720&maxdate=1187895780&who=igor%mir2.org
Status: ASSIGNED → RESOLVED
Closed: 17 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

Created:
Updated:
Size: