Closed
Bug 16732
Opened 25 years ago
Closed 25 years ago
Need definition of inline functions before use in nsDST.cpp
Categories
(Core :: Layout, defect, P3)
Tracking
()
VERIFIED
FIXED
People
(Reporter: tor, Assigned: troy)
Details
Your recent change to layout/html/base/src/nsDST.cpp (1.12) caused a couple of inline functions to be called before they were defined. The native compiler on my platform (Solaris) can't deal with this. This simple patch moves the definitions of nsDST::DestroyNode before nsDST::FreeTree: Index: nsDST.cpp =================================================================== RCS file: /cvsroot/mozilla/layout/html/base/src/nsDST.cpp,v retrieving revision 1.13 diff -u -r1.13 nsDST.cpp --- nsDST.cpp 1999/10/18 20:16:49 1.13 +++ nsDST.cpp 1999/10/18 22:53:14 @@ -305,6 +305,24 @@ mArena->Release(); } +// Called by Remove() to destroy a node. Explicitly calls the destructor +// and then asks the memory arena to free the memory +inline void +nsDST::DestroyNode(LeafNode* aLeafNode) +{ + aLeafNode->~LeafNode(); // call destructor + mArena->FreeNode(aLeafNode); // free memory +} + +// Called by Remove() to destroy a node. Explicitly calls the destructor +// and then asks the memory arena to free the memory +inline void +nsDST::DestroyNode(TwoNode* aTwoNode) +{ + aTwoNode->~TwoNode(); // call destructor + mArena->FreeNode(aTwoNode); // free memory +} + void nsDST::FreeTree(LeafNode* aNode) { @@ -358,24 +376,6 @@ aNode = ((TwoNode*)aNode)->mRight; goto keepLooping; } -} - -// Called by Remove() to destroy a node. Explicitly calls the destructor -// and then asks the memory arena to free the memory -inline void -nsDST::DestroyNode(LeafNode* aLeafNode) -{ - aLeafNode->~LeafNode(); // call destructor - mArena->FreeNode(aLeafNode); // free memory -} - -// Called by Remove() to destroy a node. Explicitly calls the destructor -// and then asks the memory arena to free the memory -inline void -nsDST::DestroyNode(TwoNode* aTwoNode) -{ - aTwoNode->~TwoNode(); // call destructor - mArena->FreeNode(aTwoNode); // free memory } nsDST::LeafNode*
Where in the language does it say that inline functions need to be defined before they're called? Or is this a known restriction of the Solaris compiler?
The compiler is also happy if you tell it that the function/method is going to be inline and then call it before the definition. Thus the following code is acceptable, but if you remove the "inline" in the class definition the compiler will report an error: class X { inline int foobar(void); void baz(void); }; void X::baz(void) { foobar(); } inline int X::foobar(void) { return 0; } The part of C++ specification relevant to this is probably 7.1.1.7 (dcl.stc part 7) - "The linkages implied by successive declarations for a given entity shall agree. That is, within a given scope, each declaration declaring the same object or the same overloading of a function name shall imply the same linkage."
That doesn't really make sense. If it were true that the linkage of the declaration and the definition must agree, then how come the compiler is happy if the definitions of DestroyNode() come before FreeTree()? The linkages don't agree in that case
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Moved the DestroyNode() functions before FreeTree() to make the Solaris compiler happy
Updated•25 years ago
|
Status: RESOLVED → VERIFIED
Comment 5•25 years ago
|
||
Based on Troy's remarks, marking as verified fixed.
You need to log in
before you can comment on or make changes to this bug.
Description
•