Hi,
It seems not a bug of managed call to wcschr function, my opinion is that
the wcschr will return a wchar_t pointer, for C++ run-time function, the
wchar_t is defined as unsigned short which the wcschr would accept, but in
managed C++, if you compile with the /Zc:wchar_t compliance switch, the
compiler enable wchar_t as an intrinsic type System::Char, so the wcschr
call's return value is not incompatible with the System::Char* p...
I tested the program will work as expected as compile with "cl /clr
bug.cpp"
:aa
:aa
Thanks!
Best regards,
Gary Chang
Microsoft Online Partner Support

Signature
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
nospam@cristalink.com - 07 Oct 2004 09:40 GMT
Thank you for your response, but you are not right.
wcschr() takes "const wchar_t*" and returns "wchar_t*". So as long as I
assign the result to "wchar_t*" or "const wchar_t*", all should work. Yes,
the bug appears only when I enable the native wchar_t type, which is not
System::Char (managed), by the way, but just a native C++ type.
The problem happens in 7.1 and fixed in 8.0, so I don't think Microsoft will
fix the bug in 7.1.
Cheers
> Hi,
>
[quoted text clipped - 20 lines]
> This posting is provided "AS IS" with no warranties, and confers no rights.
> --------------------
"Gary Chang" - 08 Oct 2004 04:21 GMT
Hi,
I have consulted this problem with the VC dev team members, when you enable
the /Zc:wchar_t compliance switch, the wchar_t would be defined as managed
"chars(System::Char) in managed compile unit.
They confirmed this problem is caused by the wchar_t type is not always
marshaled correctly across managed/unmanaged transition boundaries in VC
7.1 2003.
It is a known issue in VS.NET 2003, and was fixed in Whidbey.
Thanks for your understanding!
Best regards,
Gary Chang
Microsoft Online Partner Support

Signature
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
"Gary Chang" - 11 Oct 2004 02:24 GMT
Hi,
Do you have any more concerns on this issue, if so please feel free to post
here.
Good Luck!
Best regards,
Gary Chang
Microsoft Online Partner Support

Signature
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------