Hi all,
yesterday I did some porting of my code from the MSVC 7.1 compiler to GNU
3.3 and found the following typo flaw. Interestingly enough the code
compiled and ran fine under MSVC but GCC complained, as I would have
expected. However, I did not yet figure out why it worked under MSVC and
probably somebody can shed some light on this:
if( !pNode->IsValid() ) {
pNode->SetDirty( pNode->GetFather()->IsDirty ); // IMPORTANT: This
should read ->IsDirty() as it is a function returning a bool!
}
The declaration of SetDirty looks like this:
SetDirty( bool bFlag );
The declaration of IsDirty() looks like:
bool IsDirty() const;
Is there anybody who has an idea?
Thanks
Chris 7 1553
> pNode->GetFather()->IsDirty
This gets the function pointer of "IsDirty", which could be NULL which
is 'false' read as a bool or a function and then "an address" = 'true'.
Marcus Wentink
Chris Theis <ch*************@nospam.cern.ch> wrote: Hi all,
yesterday I did some porting of my code from the MSVC 7.1 compiler to GNU 3.3 and found the following typo flaw. Interestingly enough the code compiled and ran fine under MSVC but GCC complained, as I would have expected. However, I did not yet figure out why it worked under MSVC and probably somebody can shed some light on this:
if( !pNode->IsValid() ) { pNode->SetDirty( pNode->GetFather()->IsDirty ); // IMPORTANT: This should read ->IsDirty() as it is a function returning a bool! }
The declaration of SetDirty looks like this:
SetDirty( bool bFlag );
The declaration of IsDirty() looks like:
bool IsDirty() const;
Is there anybody who has an idea?
According to 4.12/1 pointers to members can be converted to bool,
which seems to be happening implicitly above. So I would assume VC++ 7.1
to be correct on this one.
hth
--
jb
(reply address in rot13, unscramble first)
Jakob Bieling wrote: Chris Theis <ch*************@nospam.cern.ch> wrote: Hi all,
yesterday I did some porting of my code from the MSVC 7.1 compiler to GNU 3.3 and found the following typo flaw. Interestingly enough the code compiled and ran fine under MSVC but GCC complained, as I would have expected. However, I did not yet figure out why it worked under MSVC and probably somebody can shed some light on this:
if( !pNode->IsValid() ) { pNode->SetDirty( pNode->GetFather()->IsDirty ); // IMPORTANT: This should read ->IsDirty() as it is a function returning a bool! }
The declaration of SetDirty looks like this:
SetDirty( bool bFlag );
The declaration of IsDirty() looks like:
bool IsDirty() const;
Is there anybody who has an idea? According to 4.12/1 pointers to members can be converted to bool,
But IsDirty is not a pointer to member. Member functions are not converted
into pointers to them implicitly, like nonmember functions. You have to use
the & operator to get the address.
which seems to be happening implicitly above. So I would assume VC++ 7.1 to be correct on this one.
I'd say it isn't.
Rolf Magnus wrote: Jakob Bieling wrote:
Chris Theis <ch*************@nospam.cern.ch> wrote: Hi all,
yesterday I did some porting of my code from the MSVC 7.1 compiler to GNU 3.3 and found the following typo flaw. Interestingly enough the code compiled and ran fine under MSVC but GCC complained, as I would have expected. However, I did not yet figure out why it worked under MSVC and probably somebody can shed some light on this:
if( !pNode->IsValid() ) { pNode->SetDirty( pNode->GetFather()->IsDirty ); // IMPORTANT: This should read ->IsDirty() as it is a function returning a bool! }
The declaration of SetDirty looks like this:
SetDirty( bool bFlag );
The declaration of IsDirty() looks like:
bool IsDirty() const;
Is there anybody who has an idea? According to 4.12/1 pointers to members can be converted to bool,
But IsDirty is not a pointer to member. Member functions are not converted into pointers to them implicitly, like nonmember functions. You have to use the & operator to get the address.
I think that a default compiler extension in 7.1 is to not require the
&, whether that applies to lookup of the conversion as well, I'm not sure.
Ben Pope
--
I'm not just a number. To many, I'm known as a string... ma*********@hotmail.com wrote: pNode->GetFather()->IsDirty
This gets the function pointer of "IsDirty", which could be NULL which is 'false' read as a bool or a function and then "an address" = 'true'.
Well, yes, but that's a Microsoft extension. The only standard syntax
for taking the address of a member function is with a qualified name,
i.e. classname::functionname.
--
Pete Becker
Roundhouse Consulting, Ltd.
Pete Becker wrote: Well, yes, but that's a Microsoft extension. The only standard syntax for taking the address of a member function is with a qualified name, i.e. classname::functionname.
Whoops, that's also a Microsoft extension. The standard syntax for
taking the address of a member function requires an & and a qualified
name, i.e. &classname::functionname.
--
Pete Becker
Roundhouse Consulting, Ltd.
"Rolf Magnus" <ra******@t-online.de> wrote in message
news:du*************@news.t-online.com... Jakob Bieling wrote:
Chris Theis <ch*************@nospam.cern.ch> wrote: Hi all,
yesterday I did some porting of my code from the MSVC 7.1 compiler to GNU 3.3 and found the following typo flaw. Interestingly enough the code compiled and ran fine under MSVC but GCC complained, as I would have expected. However, I did not yet figure out why it worked under MSVC and probably somebody can shed some light on this:
if( !pNode->IsValid() ) { pNode->SetDirty( pNode->GetFather()->IsDirty ); // IMPORTANT: This should read ->IsDirty() as it is a function returning a bool! }
The declaration of SetDirty looks like this:
SetDirty( bool bFlag );
The declaration of IsDirty() looks like:
bool IsDirty() const;
Is there anybody who has an idea?
According to 4.12/1 pointers to members can be converted to bool,
But IsDirty is not a pointer to member. Member functions are not converted into pointers to them implicitly, like nonmember functions. You have to use the & operator to get the address.
which seems to be happening implicitly above. So I would assume VC++ 7.1 to be correct on this one.
I'd say it isn't.
Yes, that's what I also thought. But it seems that this is really a
"feature" of a MS extension, as Pete pointed out.
Thanks guys
Chris This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Alf P. Steinbach |
last post by:
// As usual the error message directs one to the report the bug.
//
// And as usual there is absolutely no way to do so without paying for
// the privilege...
//
// Or using three or four hours...
|
by: Praveen |
last post by:
Hi,
I have installed WebSphere Portal on AIX and connected to DB2 on a
remote machine, Getting the followin errors when trying to get the
values from database thru applications installed on...
|
by: Rudy Ray Moore |
last post by:
Whenever I get any error with Vc++7.1/.net/2003, it is followed by huge
ammounts of "template assistance" error messaging referencing template code
(MTL) that has nothing to do with the error.
...
|
by: Cynthia |
last post by:
Hi,
I have a C++ source file (mymessage.cpp), it is used by two different
platforms. PC and VxWorks.
The file has a header section to include header files depending on which
platform it is...
|
by: Peter Oliphant |
last post by:
For some reson my code is generating a LNK1215 error, which 'suggests' I
re-install VS C++. So I did. which did NOT solve the problem. The weid part
is it seems to be caused by my one CPP file, but...
|
by: Jim in Arizona |
last post by:
I'm doing my best to learn ASPNET from a book devoted to ASPNET 1.0. So far,
I haven't run into any problems, until now.
This is a simple page that should just show the sql strings created by the...
|
by: mario.zoric |
last post by:
Hi to all!
I have one big problem. I have written some code and I want to program
at the end looks good but theres one uninspected error.
What's going on?
I have written code for programm that...
|
by: milund |
last post by:
I have a "funny" after upgrading to .NET2.0.
The following code is placed inside an unsafe method in assembly "A"
System.Object myIUnknownObject =...
|
by: MisterE |
last post by:
typedef struct sg
{
int a;
} G;
int c(G* g)
{
return g->a;
}
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| | |