Closed Bug 20833 Opened 25 years ago Closed 25 years ago

Build warning caused by bug in xpidl, converting unsigned positive number to negative number

Categories

(Core :: XPCOM, defect, P3)

defect

Tracking

()

VERIFIED FIXED

People

(Reporter: bratell, Assigned: mike+mozilla)

References

Details

Attachments

(1 file)

During a build I get lots of
..\..\..\..\dist\include\nsIFileSpecWithUI.h(45) : warning C4146: unary minus
operator applied to unsigned type, result still unsigned

Looking at the code this is caused by
    enum { eExtraFilter = -2147483648 };

which is generated by xpidl when compiling nsIFileSpecWithUI.idl. The source
line in that file is

const unsigned long eExtraFilter = 1<<31;

Apparently a "unsigned long 1<<31" is converted to "-2147483648" which surely is
wrong. I don't know if this causes a bug when using the file. If I get the bit
arithmetic right "-2147483648" and "2147483648" is the same bit pattern when
using two complement, but we might not always be so lucky.

I didn't know what component to assign this bug to so be free to reassign as
appropriate.
Found the xpidl component in Bugzilla. Reassigning to mccabe.
Assignee: leger → mccabe
Component: Browser-General → xpidl
Status: NEW → ASSIGNED
QA Contact: leger → rginda
Thanks for finding this.

Marking as assigned and changing QA contact.
Attaching proposed fix.  With m12 and dogfood, it might be a while before I land
it.

bratell -

I'm not totally familiar with just what can go into an enum (signed, unsigned,
long, etc.) or with number type conversions and the printf % formats I used in
the fix.  It seems to work...

Could you take a look and tell me if what I'm doing makes sense?  Am I doing a
lot of extra work to do something that could be handled by automatic conversions
except in the case you noticed?

Thanks -

Mike
I'm no guru either but I've applied the patch and the warnings are gone. I'm a
little unsure about the "ld" and "lu" arguments to printf. I _think_ that 'l'
specifies that the given variable is a long variable but I couldn't find the
type of IDL_INTEGER(dcl->const_exp).value so I don't know what's correct. As
both int and long are 32-bit on all modern platforms I'm aware of, it may be a
benign big in the worst case. Apart from that the patch looks good to me.
*** Bug 22014 has been marked as a duplicate of this bug. ***
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Fix checked in.  Thanks for confirming it :)
Status: RESOLVED → REOPENED
Reopening bug.

I had to revert this fix, because it caused mac, solaris and linux/ppc to
generate '0' for consts.  Needless to say, this lead to trouble elsewhere in the
tree.  I'm looking for clues as to why this triggered a cross-platform
difference... changed file was xpidl_header.c.
Resolution: FIXED → ---
Clearing FIXED resolution due to reopen.
Status: REOPENED → RESOLVED
Closed: 25 years ago25 years ago
Resolution: --- → FIXED
Fix checked in.
Yes. Old bug.  fixed on all platforms for some time.  Marking Verified.
Status: RESOLVED → VERIFIED
Component: xpidl → XPCOM
QA Contact: rginda → xpcom
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: