C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Promotion converts long int to int implicitly ?

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Timothy Madden
Guest





PostPosted: Mon Sep 27, 2004 9:39 am    Post subject: Promotion converts long int to int implicitly ? Reply with quote



Hello

I have an overloaded function like this:

BOOL SetFieldValue(_RecordsetPtr, LPCTSTR, long);
BOOL SetFieldValue(_RecordsetPtr, LPCTSTR, int);

And then I call the function like this:
SetFieldValue(pRecordset, _T("Order"), long(i)+1);
and the debugger shows that the int overload of my fuction is called.

Is long( i ) + 1 not of type long ? Why is the int overload selected ?

Thank you
Timothy Madden
Romania
-----------------------------------------
And I don't wanna miss a thing


Back to top
Jacques Labuschagne
Guest





PostPosted: Mon Sep 27, 2004 9:53 am    Post subject: Re: Promotion converts long int to int implicitly ? Reply with quote



Timothy Madden wrote:
Quote:
Hello

I have an overloaded function like this:

BOOL SetFieldValue(_RecordsetPtr, LPCTSTR, long);
BOOL SetFieldValue(_RecordsetPtr, LPCTSTR, int);

And then I call the function like this:
SetFieldValue(pRecordset, _T("Order"), long(i)+1);
and the debugger shows that the int overload of my fuction is called.

Is long( i ) + 1 not of type long ? Why is the int overload selected ?

This seems contrary to the standard, which says in section 5, point 9,
item 7: "Otherwise, if either operand is long, the other shall be
converted to long."

Jacques.

Back to top
Victor Bazarov
Guest





PostPosted: Mon Sep 27, 2004 5:12 pm    Post subject: Re: Promotion converts long int to int implicitly ? Reply with quote



Jacques Labuschagne wrote:
Quote:
Timothy Madden wrote:

Hello

I have an overloaded function like this:

BOOL SetFieldValue(_RecordsetPtr, LPCTSTR, long);
BOOL SetFieldValue(_RecordsetPtr, LPCTSTR, int);

And then I call the function like this:
SetFieldValue(pRecordset, _T("Order"), long(i)+1);
and the debugger shows that the int overload of my fuction is called.

Is long( i ) + 1 not of type long ? Why is the int overload selected ?


This seems contrary to the standard, which says in section 5, point 9,
item 7: "Otherwise, if either operand is long, the other shall be
converted to long."

It is contrary to the Standard, but it is also a bug in VC++ v 6. It
was apparently fixed in v 7[.1]

V

Back to top
Old Wolf
Guest





PostPosted: Mon Sep 27, 2004 9:10 pm    Post subject: Re: Promotion converts long int to int implicitly ? Reply with quote

"Timothy Madden" <batman (AT) rmv (DOT) spam.home.ro> wrote:
Quote:
Hello

I have an overloaded function like this:

BOOL SetFieldValue(_RecordsetPtr, LPCTSTR, long);
BOOL SetFieldValue(_RecordsetPtr, LPCTSTR, int);

And then I call the function like this:
SetFieldValue(pRecordset, _T("Order"), long(i)+1);
and the debugger shows that the int overload of my fuction is called.

Possibly your compiler has optimised away the 'long' overload,
try turning off all optimisation and then tracking it again.

Back to top
Timothy Madden
Guest





PostPosted: Tue Sep 28, 2004 6:31 am    Post subject: Re: Promotion converts long int to int implicitly ? Reply with quote


"Victor Bazarov" <v.Abazarov (AT) comAcast (DOT) net> wrote

Quote:
Jacques Labuschagne wrote:
Timothy Madden wrote:

Hello

I have an overloaded function like this:

BOOL SetFieldValue(_RecordsetPtr, LPCTSTR, long);
BOOL SetFieldValue(_RecordsetPtr, LPCTSTR, int);

And then I call the function like this:
SetFieldValue(pRecordset, _T("Order"), long(i)+1);
and the debugger shows that the int overload of my fuction is called.

Is long( i ) + 1 not of type long ? Why is the int overload selected ?


This seems contrary to the standard, which says in section 5, point 9,
item 7: "Otherwise, if either operand is long, the other shall be
converted to long."

It is contrary to the Standard, but it is also a bug in VC++ v 6. It
was apparently fixed in v 7[.1]

Oh, thank you very much !!

I'm happy someone else knows about this problem.

Can you tell me exactly what the bug is and where can I find a list with VC
6 bugs if it exists ?
I did encounter other problems like this in my app

Thank you
Timothy Madden
Romania
-------------------------------------------------------------
And I don't wanna miss a thing



Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.