Closed
Bug 188141
Opened 22 years ago
Closed 22 years ago
NS_CONST_CAST, NS_REINTERPRET_CAST, and NS_STATIC_CAST are not protected with parentheses properly
Categories
(Core :: XPCOM, defect)
Core
XPCOM
Tracking
()
RESOLVED
INVALID
People
(Reporter: benjamin, Assigned: benjamin)
References
Details
Attachments
(1 file)
1.21 KB,
patch
|
Details | Diff | Splinter Review |
The macro definitions of NS_STATIC_CAST, NS_CONST_CAST, and NS_REINTERPRET_CAST are not protected properly with parentheses. This can lead to order-of-operations errors, as a trivial example: NS_REINTERPRET_CAST(nsISupports*,somevoidpointer)->AddRef(); will fail because -> is higher precedence than the cast operator. Patch forthcoming.
Assignee | ||
Comment 1•22 years ago
|
||
Assignee | ||
Comment 2•22 years ago
|
||
Oops, accidentally clicked wrong component.
Status: NEW → ASSIGNED
Component: XP Toolkit/Widgets: XUL → XPCOM
QA Contact: shrir → scc
Assignee | ||
Updated•22 years ago
|
Attachment #110920 -
Flags: superreview?(scc)
Attachment #110920 -
Flags: review?(dougt)
static_cast<T>() has the parentheses as part of the syntax -- see C++ section 5.2 clause 1. The pattern that you say won't work is used all over the codebase (for example, the first occurrence of NS_STATIC_CAST in nsBlockFrame.cpp), so I don't think there are any compilers that do this wrong, either.
Assignee | ||
Comment 4•22 years ago
|
||
Oops, my bad. I misunderstood a compiler error during casting.
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → INVALID
Assignee | ||
Updated•22 years ago
|
Attachment #110920 -
Flags: superreview?(scc)
Attachment #110920 -
Flags: review?(dougt)
You need to log in
before you can comment on or make changes to this bug.
Description
•