 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Timothy Madden Guest
|
Posted: Mon Sep 27, 2004 9:39 am Post subject: Promotion converts long int to int implicitly ? |
|
|
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
|
Posted: Mon Sep 27, 2004 9:53 am Post subject: Re: Promotion converts long int to int implicitly ? |
|
|
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
|
Posted: Mon Sep 27, 2004 5:12 pm Post subject: Re: Promotion converts long int to int implicitly ? |
|
|
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
|
Posted: Mon Sep 27, 2004 9:10 pm Post subject: Re: Promotion converts long int to int implicitly ? |
|
|
"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
|
Posted: Tue Sep 28, 2004 6:31 am Post subject: Re: Promotion converts long int to int implicitly ? |
|
|
"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 |
|
 |
|
|
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
|
|