Subject: Re: commit - Fix persistent ignore words stuff
From: Mike Nordell (tamlin@algonet.se)
Date: Sun Mar 25 2001 - 18:38:27 CST
Tom Briggs wrote:
> I don't have the first idea why the MSVC compiler didn't like the
> following:
>
> DELETEP((UT_UCSChar *)pHE->pData);
Here you're trying to delete one UT_UCSChar that must have been allocated
by the following expression to not invoke undefined behaviour.
new UT_UCSChar;
It's obvious that this is not the case...
The expression that fails is (expanded):
((UT_UCSChar*)pHE->pData) = 0;
Let's boil it down to:
void* p;
(char*)p = 0;
Bcc5.5 thinks the expression "(char*)p" is an lvalue, but both MSVC and
comeau agrees it's an rvalue. A believe como and M$ are right.
I might by this also put in my vote to drop these macros (in case someone
believed I wanted to keep them) for the explicit (and understandable) form:
delete[] (UT_UCSChar *)pHE->pData;
pHE->pData = 0;
As we (once again) can see these macros are hurting readability and
understandability. Had these macros not hidden this it would have been a
rather obvious error to not call the array form of delete. I can't imagine
how anyone came to believe these macros help _reduce_ bugs. We have seen at
least two indications in just the last week they hurt.
/Mike - don't cc
This archive was generated by hypermail 2b25 : Sun Mar 25 2001 - 18:39:50 CST