Author |
Topic |
|
PatLuja
Tomato Guru
Belgium
416 Posts |
Posted - Feb 10 2004 : 04:10:47 AM
|
Hello all,
I don't know exactly wheather or not this bug has already been remarked previously.
I have code like:if (CMyClass* pMyClass=new CMyClass()) {
//...
pMyClass->MyFunction();
//...
} pMyClass isn't recognized: - It's coloured black, - It doesn't appear in the autocompletion listbox, - No other listboxes appear when I want to use pMyClass.
Could you please look into this matter? Thank you in advance
With kind regards, Patrick Luja
P.S. I'm using build 1215 |
|
LarryLeonard
Tomato Guru
USA
1041 Posts |
Posted - Feb 10 2004 : 09:50:00 AM
|
As an aside, what is this if statement trying to do? Under what circumstance would the if statement ever be false? (Hmmm... maybe you're using your own new operator?)
|
|
|
Baga
Tomato Guru
122 Posts |
Posted - Feb 11 2004 : 01:35:33 AM
|
Even regular 'new' may fail (return NULL) in case there is no memory. |
|
|
LarryLeonard
Tomato Guru
USA
1041 Posts |
|
ChainsaW
Junior Member
Czech Republic
13 Posts |
Posted - Feb 11 2004 : 10:23:10 AM
|
quote: Originally posted by LarryLeonard
Oh, I forgot. This is Microsoft, so the compiler doesn't actually follow the standard...
Beginning in Visual C++ .NET 2002, the new function in the Standard C++ library will support the behavior specified in the C++ standard, which is to throw a std::bad_alloc exception if the memory allocation fails.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/_pluslang_the_new_and_delete_operators.asp
However, you can create a custom new operator that can return NULL value to indicate allocation failure, as described in the C++ ISO specification (3.7.3.1):
If an allocation function declared with an empty exception specification (15.4), throw(), fails to allocate storage, it shall return a null pointer.
|
|
|
PatLuja
Tomato Guru
Belgium
416 Posts |
Posted - Feb 20 2004 : 02:55:23 AM
|
Hello all,
Beside the interesting discussion on how the code could be made nicer, what about the real matter. The variable inside the if-statement isn't recognized.
Has anyone else seen this?
And could the fine team of WholeTomato, please, do something about it? Thank you.
With kind regards, Patrick Luja |
|
|
support
Whole Tomato Software
5566 Posts |
Posted - Mar 01 2004 : 12:03:09 PM
|
Fixed in build 1218. |
Whole Tomato Software, Inc. |
|
|
Old as dirt
Tomato Guru
USA
246 Posts |
Posted - Mar 02 2004 : 12:58:10 PM
|
Since it has been fixed I feel OK about rambling on a bit. How do you tell if you have accidentally made an assignment inside a conditional statement? I can't believe that there is any difference in the object code if you do the new just before the if. Not to get around the problem you presented to the Tomato, but to take advantage of some of the checking that is done for you. Ken |
Ken |
|
|
PatLuja
Tomato Guru
Belgium
416 Posts |
Posted - Mar 04 2004 : 03:05:22 AM
|
Hello,
It's a problem I've encountered when looking through some code that was new for me; it was written by someone else. I do prefer the new before the if-statement, while some others prefer it in the if-statement (it should be a little bit faster). But since I encounter such behaviour (and maybe some other programmers do also), and since I'm used to reading code with all the VissualAssist enhancements, it disturbed me (a little) that every time I encountered a variable that was declared this way, it wasn't treated as a variable.
So I just brought it up.
Thanks to the team of Whole Tomato for fixing this.
With kind regards, Patrick Luja
|
|
|
|
Topic |
|