Promotion converts long int to int implicitly ?

T

Timothy Madden

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
 
J

Jacques Labuschagne

Timothy said:
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.
 
V

Victor Bazarov

Jacques said:
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
 
O

Old Wolf

Timothy Madden said:
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.
 
T

Timothy Madden

Victor Bazarov said:
Jacques said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top