Search

x86 C++ compiler crash by Nico Rieck

Closed

1
0
Sign in
to vote
Type: Bug
ID: 772093
Opened: 11/24/2012 8:29:10 AM
Access Restriction: Public
1
Workaround(s)
0
User(s) can reproduce this bug
The attached test case results in a C++ compiler crash. It happens with both 17.00.50727.1 and 17.00.51025 x86; x64 compiles fine.

The test case itself is heavily reduced from code involving member function pointers, with the union_cast used to retrieve the address of a member function. It seems I cannot remove anything else or the crash goes away.
Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling Version

Visual Studio 2012

Steps to reproduce

Compile one of the attached files with the x86 cl.exe (17.00.50727.1 or 17.00.51025).
No special command line flags are required, just "cl <file>.cpp".

Product Language

English

Operating System

Any

Operating System Language

English

Actual results

C:\>cl crash.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 17.00.50727.1 for x86
Copyright (C) Microsoft Corporation. All rights reserved.

crash.cpp
crash.cpp(12) : fatal error C1001: An internal error has occurred in the compiler.
(compiler file 'msc1.cpp', line 1443)
To work around this problem, try simplifying or changing the program near the locations listed above.
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
        crash.cpp(39) : see reference to function template instantiation 'Target crash::union_cast<unsigned int,void(__thiscall crash::X::* )(void)>(Source)' being compiled
        with
        [
            Target=unsigned int,
            Source=void (__thiscall crash::X::* )(void)
        ]
Internal Compiler Error in C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN\cl.exe. You will be prompted to send an error report to Microsoft later.

C:\>cl crash.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 17.00.51025 for x86
Copyright (C) Microsoft Corporation. All rights reserved.

crash.cpp
crash.cpp(12) : fatal error C1001: An internal error has occurred in the compiler.
(compiler file 'msc1.cpp', line 1453)
To work around this problem, try simplifying or changing the program near the locations listed above.
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
        crash.cpp(39) : see reference to function template instantiation 'Target crash::union_cast<unsigned int,void(__thiscall crash::X::* )(void)>(Source)' being compiled
        with
        [
            Target=unsigned int
,            Source=void (__thiscall crash::X::* )(void)
        ]
Internal Compiler Error in C:\Program Files (x86)\Microsoft Visual C++ Compiler Nov 2012 CTP\bin\cl.exe. You will be prompted to send an error report to Microsoft later.

Expected results

Successful compilation (or at least no compiler crash).
File Attachments
File Name Submitted By Submitted On File Size  
crash.cpp 11/24/2012 720 bytes
crash-preprocessed.cpp 11/24/2012 830 KB
Sign in to post a comment.
Posted by Microsoft on 12/25/2012 at 11:17 AM
Hi:
    Thanks for reporting the issue.
    A fix for this issue has been checked into the compiler sources. The fix should show up in the next release of Visual C++.

Xiang Fan
Visual C++ Team
Posted by Microsoft on 11/26/2012 at 12:27 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 11/24/2012 at 8:51 AM
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.
Posted by Nico Rieck on 11/24/2012 at 8:35 AM
Instead of union_cast these templates can be used to retrieve the address:

    template<typename T, typename R, typename... Params>
    uintptr_t memfn_addr(R (__thiscall T::*fn)(Params...))
    {
        return *reinterpret_cast<uintptr_t*>(&fn);
    }

    template<typename T>
    uintptr_t memfn_addr(T fn)
    {
        return *reinterpret_cast<uintptr_t*>(&fn);
    }