Home Dashboard Directory Help
Search

Internal Compiler Error using const wchar_t* in inline method by Henri Hein


Status: 

Closed
 as Fixed Help for as Fixed


1
0
Sign in
to vote
Type: Bug
ID: 761148
Opened: 9/4/2012 1:35:48 PM
Access Restriction: Public
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

I have an inline method taking a whcar_t*. When I constify this parameter, I get an internal compiler error. Cannot see anything mystical about it.
Details
Sign in to post a comment.
Posted by Microsoft on 9/14/2012 at 2:03 PM
Hi Henri:
    Which version of VS2012 do you use? The ICE is fixed in RTM version of VS2012.
    However, the compiler will now give the following error:

error C4400: 'const wchar_t' : const/volatile qualifiers on this type are not supported

    When you use 'protected', 'DLog' becomes a public interface of 'CCompilerErrTest' and is put into the generated winmd file, so that other language (like C#) can call it.
    winmd doesn't support 'const' or 'volatile' (it is a C++ specific concept), so the compiler gives the error.
    Also note that, 'wchar_t *' is translated to a by-reference parameter of type 'Platform::Char' in the winmd, which is different from a wide-string in C++. Use 'Platform::String^' if you want to pass string between different winmds.

    If you don't want to expose 'DLog' outside of your winmd, you can use 'private protected' instead of 'protected'.
Posted by Henri Hein on 9/13/2012 at 6:21 PM
I was able to reproduce in a small project and attached it. Good luck!
Posted by Microsoft on 9/11/2012 at 3:08 PM
Hi Henri,
    Thanks for reporting the issue.
    Unfortunately, we can't repro the issue following your steps.
    The error message you see is the general message when the compiler hits internal issues and doesn't have enough information for us to further investigate.
    A self-contained repro is appreciated.

    The code we tried:

#include <strsafe.h>
#include <windows.h>

struct S {
    inline void DLog(const wchar_t* str, int ipar = 0)
    {
        wchar_t out[1024];
        StringCbPrintf(out, sizeof(out), str, ipar);
        OutputDebugStringW(out);
    }
};

int main()
{
    S s;
    s.DLog(L"");
}
Posted by Henri Hein on 9/10/2012 at 10:04 PM
Sorry, for some reason I did not receive the earlier comments. I did not try to reproduce the problem in a separate project. I thought the message from the compiler would give a clue. I get around it by just not using const for now.
Posted by Microsoft on 9/10/2012 at 1:29 AM
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by Microsoft on 9/6/2012 at 12:35 AM
I am currently standing by for an update from you and would like to know how things are going on your end. If you could get back to me at your earliest convenience with information I request, we will be able to make headway towards a resolution. I look forward to hearing from you.
Posted by Microsoft on 9/4/2012 at 9:26 PM
I am having trouble reproducing your issue. Can you share a sample project on which you are seeing this problem?

Thanks
Posted by Microsoft on 9/4/2012 at 1:51 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
File Name Submitted By Submitted On File Size  
CompilerErrTest.zip 9/13/2012 3 KB