Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / October 2004

Tip: Looking for answers? Try searching our database.

VC7.1 bug: managed call to wcschr

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
nospam@cristalink.com - 06 Oct 2004 08:26 GMT
/// Compile with "cl  /Zc:wchar_t  /clr  bug.cpp"

#include <stdio.h>
#include <string.h>

#define TEST    const wchar_t* p = wcschr( L"aa:aa", L':' ); printf(
"%ls\n", p );

#pragma managed
void f_managed()
{
  TEST
}

#pragma unmanaged
void f_unmanaged()
{
  TEST
}

#pragma managed
void main()
{
  f_managed();
  f_unmanaged();
}

Results:

(null)
:aa
"Gary Chang" - 07 Oct 2004 07:49 GMT
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.

--------------------

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.