Closed
Bug 344135
Opened 19 years ago
Closed 18 years ago
jsgc.c line 323 won't compile in DEBUG
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: MikeM, Unassigned)
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4
jsgc.c line 323 is broke and won't compile in DEBUG.
Here's the offending line of code:
--------------------------------------------------
JS_STATIC_ASSERT(2 <= sizeof table->array[0]);
--------------------------------------------------
Here's the compiler errors:
------------------------------------------
syntax error : missing ')' before '+'
syntax error : missing ';' before '+'
syntax error : ')'
subscript requires array or pointer type
------------------------------------------
Compiled using VC++ 6.0 with the latest SP.
Source was taken from CVS head today (7/10/2006).
Reproducible: Always
Comment 1•19 years ago
|
||
Not a problem with VS7.x and VS8, or with GCC. Igor, any ideas?
/be
Status: UNCONFIRMED → NEW
Ever confirmed: true
| Reporter | ||
Comment 2•19 years ago
|
||
There is also a warning on line 1230:
----------------
arenaList->lastLimit = offset;
----------------
conversion from 'unsigned long ' to 'unsigned short ', possible loss of data
The lastLimit variable is defined as uint16 and offset is a jsuword
Just a little cleanup...
| Reporter | ||
Comment 3•19 years ago
|
||
If I change the line from:
JS_STATIC_ASSERT(2 <= sizeof table->array[0]);
to:
JS_STATIC(2 <= sizeof table->array[0]);
Then it compiles fine.
I did notice that AddToPtrTable() is a static function.
However I don't know the difference between the two macros or the ramifications of this change. Just thought I'd point this out.
Comment 4•19 years ago
|
||
(In reply to comment #3)
> JS_STATIC(2 <= sizeof table->array[0]);
Did you mean JS_ASSERT?
/be
| Reporter | ||
Comment 5•19 years ago
|
||
Doh!
Yes I meant JS_ASSERT()
Sorry for the confusion.
Comment 6•19 years ago
|
||
(In reply to comment #1)
> Not a problem with VS7.x and VS8, or with GCC. Igor, any ideas?
The strange thing is that it affects only DEBUG build when JS_STATIC_ASSERT is defined unconditionally. Does VC6 really can compile without DEBUG? And if this is a bug in VC6, then what happens if
JS_STATIC_ASSERT(2 <= sizeof table->array[0]);
would be replaced by
JS_STATIC_ASSERT(2 <= sizeof(void *));
?
| Reporter | ||
Comment 7•19 years ago
|
||
>The strange thing is that it affects only DEBUG build when JS_STATIC_ASSERT is
>defined unconditionally.
Asserts are defined to nothing in a release build, which is why it affects only DEBUG.
I've tried a bunch of things. All the following fail with the same error.
JS_STATIC_ASSERT(2 <= sizeof(void *));
JS_STATIC_ASSERT(2 <= 2);
JS_STATIC_ASSERT(1);
I guess that means JS_STATIC_ASSERT cannot be used in a static function.
All other static functions in this part of the code use JS_ASSERT() instead.
Brendan can you make this change?
Comment 8•19 years ago
|
||
(In reply to comment #7)
> >The strange thing is that it affects only DEBUG build when JS_STATIC_ASSERT is
> >defined unconditionally.
>
> Asserts are defined to nothing in a release build, which is why it affects only
> DEBUG.
No: JS_STATIC_ASSERT is defined unconditinally to *always* cause a compile-time error when the condition is violated, see http://lxr.mozilla.org/seamonkey/source/js/src/jsutil.h#65
>
> I've tried a bunch of things. All the following fail with the same error.
> JS_STATIC_ASSERT(2 <= sizeof(void *));
> JS_STATIC_ASSERT(2 <= 2);
> JS_STATIC_ASSERT(1);
>
> I guess that means JS_STATIC_ASSERT cannot be used in a static function.
No, it just means that VC6 can swallow typedef inside a function in this particular case. A trivial workaround would be to replace it by JS_ASSERT indeed . A better solution is to change JS_STATIC_ASSERT to take into account VC6 bug f possible.
> All other static functions in this part of the code use JS_ASSERT() instead.
It is because other conditions are not compile-time constants.
| Reporter | ||
Comment 9•18 years ago
|
||
Don't use Visual C++ 6.0 anymore... Closing bug.
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•