Closed Bug 440724 Opened 16 years ago Closed 16 years ago

Folder tree couldn't open/close Thunderbird compiling with Sun Studio 12 x86

Categories

(Core :: XUL, defect)

x86
OpenSolaris
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: ginnchen+exoracle, Assigned: ginnchen+exoracle)

Details

Attachments

(1 file, 1 obsolete file)

Compile Thunderbird with Sun Studio 12 x86.
The folder tree in the left couldn't be opened or closed.
Actually there's no twisy-open.png or twisty-clsd.png displayed.

This is a bug of Sun Studio 12, it doesn't allow "Assigning a negative value to an implicit unsigned bitfield."

So this code could not work:
 63     // N.B. these values are chosen to avoid problems with
 64     // sign-extension from the bit-packed Row structure.
 65     enum ContainerType {
 66         eContainerType_Unknown      =  0,
 67         eContainerType_Noncontainer =  1,
 68         eContainerType_Container    = -2
 69     };
 90     struct Row {
 91         nsTemplateMatch* mMatch;
 92         ContainerType    mContainerType  : 2;
 93         ContainerState   mContainerState : 2;
 94         ContainerFill    mContainerFill  : 2;
 95         
 96         Subtree*         mSubtree; // XXX eventually move to hashtable
 97     };

Compiled with current SS12, we will get mContainerType as "+2" not "-2".
The bug is logged to SS12.

According to
9.6p4 in the C++ standard:
    If the value of an enumerator is stored into a bit-field of the
    same enumeration type and the number of bits in the bit-field
    is large enough to hold all the values of that enumeration
    type (7.2), the original enumerator value and the value of the
    bit-field shall compare equal.

We can use 0,1,2 and pack it to 2bits safely, and get around SS12's bug.
Attached patch patch (obsolete) — Splinter Review
Attachment #325979 - Flags: review?(neil)
(In reply to comment #0)
> This is a bug of Sun Studio 12, it doesn't allow "Assigning a negative value to
> an implicit unsigned bitfield."
Why does it think the bitfield is unsigned? VC7.1 says it's signed.
(In reply to comment #2)
> (In reply to comment #0)
> > This is a bug of Sun Studio 12, it doesn't allow "Assigning a negative value to
> > an implicit unsigned bitfield."
> Why does it think the bitfield is unsigned? VC7.1 says it's signed.
> 

I think it's a bug of the compiler.
There might be some other compilers which have the same problem.
OK, so VC7.1 (and VC6, since I had it handy) always compiles enum as signed; gcc however (since at least 2.96) compiles it as unsigned unless it explicitly contains negative values, while Sun Studio seems to think it's always unsigned!
I think the spec is a $$$ document so someone else will have to chip in here, but I Googled around and found that ARM thinks that enums must be signed, while IBM seems to think that they will be signed unless you use large integers.
I guess the most portable solution here is to use {0,1,2} and packed into 4-bit.
It won't change the size of struct Row, I guess it's at least 16-bit aligned.

Attached patch patch v2Splinter Review
Attachment #325979 - Attachment is obsolete: true
Attachment #326298 - Flags: review?(neil)
Attachment #325979 - Flags: review?(neil)
Attachment #326298 - Flags: superreview+
Attachment #326298 - Flags: review?(neil)
Attachment #326298 - Flags: review?(enndeakin)
Attachment #326298 - Flags: review?(enndeakin) → review+
Pushed

http://hg.mozilla.org/index.cgi/mozilla-central/rev/65b3e7e453a6
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Component: XP Toolkit/Widgets: Trees → XUL
QA Contact: xptoolkit.trees → xptoolkit.widgets
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: