473,385 Members | 1,661 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

VC7.1 bug: managed call to wcschr

/// 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
Nov 17 '05 #1
4 1122
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

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

Nov 17 '05 #2
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
""Gary Chang"" <v-******@online.microsoft.com> wrote in message
news:el**************@cpmsftngxa06.phx.gbl...
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

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

Nov 17 '05 #3
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

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

Nov 17 '05 #4
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

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

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Nadav | last post by:
Hi, Introduction *************** I have a system build of a collection of 'Native COM objects' and '.NET COM interop' objects, all of the COM objects are managed through a 'Native COM' layer,...
2
by: Sai Kit Tong | last post by:
I try to utilize an old native code class library for my managed C++ application, and experience a weird problem. I used IJW approach and included the header file for my native class definition. I...
1
by: Steve Terepin | last post by:
I've found some rather worrying articles (Mixed Mode Library Assembly bug, Richard Grimes, Windows Developer Network Sept 2003 ; and Knowledge Base Article 814472 ) that point out the need to use...
5
by: nospam | last post by:
http://lab.msdn.microsoft.com/ProductFeedback/viewFeedback.aspx?feedbackId=FDBK16272
1
by: Albert Oppenheimer | last post by:
I thought my program had to be caught in a loop, and cancelled it through the task manager. It took about one second in Java, but re-implemented in C, it had already run over one minute. I set...
22
by: Albert Oppenheimer | last post by:
I thought my program had to be caught in a loop, and cancelled it through the task manager. It took about one second in Java, but re-implemented in C, it had already run over one minute. I set...
16
by: Edward Diener | last post by:
After spending more than a day reducing a complicated compiler bug to a simple case I reported it to the MSDN Product Feedback Center as a bug just now. However this bug is completely stymying my...
0
by: LiveTecs | last post by:
http://www.livetecs.com TimeLive Web Collaboration Suite is an integrated suite that allows you to manage project life cycle including tasks, issues, bugs, timesheet, expense, attendance. ...
30
by: Howard Swope | last post by:
Greetings: Is anyone aware of a fix for the apparent bug in C++ /CLI 2005... If you create a class with a ref type member variable declared with stack semantics and you declare this member as ,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.