Calling decltype(*this) crashes the compiler with C1001 - by Matt Olenik

Status : 

 


2
0
Sign in
to vote
ID 535785 Comments
Status Active Workarounds
Type Bug Repros 1
Opened 2/23/2010 6:52:09 PM
Access Restriction Public
Primary Feedback Item 535484

Description

If you have a class Foo, and try to use decltype(*this) somewhere in a method (or constructor) of that class, the compiler crashes with C1001. Example:

class Foo
{
    void bar()
    {
        decltype(*this) x();    // C1001
        decltype(*this) x;      // C1001
    }
}

I am uncertain if this is valid C++, although I don't see why it wouldn't be. In any case, if it is invalid, it should report an appropriate error message rather than crash.

Also note that this only occurs on the this pointer, with any other pointer the decltype call works as expected.
Sign in to post a comment.
Posted by Jonathan [MSFT] on 2/24/2010 at 8:23 AM
Hi: I can confirm that this is a bug with Visual C++. Unfortunately it does not meet the triage bar for the current release of Visual C++ - but we will keep the issue in our database and we will look at it again during the development phase of a future release of Visual C++.

Jonathan Caves
Visual C++ Compiler Team
Posted by Microsoft on 2/23/2010 at 7:07 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)