Closed Bug 198769 Opened 22 years ago Closed 14 years ago

Potentially unsafe cast warning issued during compilation.

Categories

(Core :: XPConnect, defect)

HP
Other
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: m4341, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [build_warning])

Attachments

(1 file)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3b) Gecko/20030210 Build Identifier: Mozilla/5.0 Version 1.3, attempted build under HP-UX with HP compilers/linkers Building under HP-UX 11.00/32-bit results in the following warning, best displayed with fixed-width font: Warning 749: "../../dist/include/xpcom/xptinfo.h", line 258 # The cast from 'con st XPTConstValue *' to 'nsXPTCMiniVariant *' is performed as a 'reinterpret_cast '. This operation is non-portable and potentially unsafe. {return (nsXPTCMiniVariant*) &value;} ^^^^^^^^^^^^^^^^^^^^ Reproducible: Always Steps to Reproduce: 1. 2. 3.
-> xpconnect
Assignee: seawood → dbradley
Component: Build Config → XPConnect
QA Contact: granrose → pschwartau
Hardware: Other → HP
Formally confirming for consideration -
Status: UNCONFIRMED → NEW
Ever confirmed: true
Blocks: buildwarning
MXR: xptinfo.h | 1.23 | { 253 // XXX this is ugly. But sometimes you gotta do what you gotta do. 254 // A reinterpret_cast won't do the trick here. And this plain C cast 255 // works correctly and is safe enough. 256 // See http://bugzilla.mozilla.org/show_bug.cgi?id=49641 257 const nsXPTCMiniVariant* GetValue() const 258 {return (nsXPTCMiniVariant*) &value;} } Should this bug be resolved as duplicate of bug 49641 !? In any case, would it be right to submit a (cleanup only) patch like { 257 const nsXPTCMiniVariant * GetValue() const 258 {return (const nsXPTCMiniVariant *) &value;} } ?
Depends on: 49641
I would have thought the problem was the lack of const, NS_REINTERPRET_CAST should work as well if constness is preserved. - {return (nsXPTCMiniVariant*) &value;} + {return NS_REINTERPRET_CAST(const nsXPTCMiniVariant*, &value);} What I'm leary of is, that there still might be some other compiler out there, that might choke on this. I'm using VC++ 7.1. Anyone want to try this with gcc, or VC++ 6?
Let's do |const| first, then we'll try |NS_REINTERPRET_CAST()|.
Comment on attachment 137959 [details] [diff] [review] (Av1) 1st, add |const| 'r=?': (see comment 5) I have no compiler: Could you compile/test/review it ? Thanks.
Attachment #137959 - Flags: review?(BradleyJunk)
Assignee: dbradley → nobody
QA Contact: pschwartau → xpconnect
Whiteboard: [build_warning]
Could not see any warning in linux, mac and windows. Since I don't have access to hpux system, I can't comment on the warning status on hpux but I really doubt this has anything to do with platform.
I think might just be worth closing as WFM, if you can't see a related warning in newer builds. Thanks for your work in going through bug 187528's dependants - it's about time these 7 year old open bugs were closed one way or another :-)
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: