C++ compiler crash - by Dmitri R. Kuvshinov

Status : 

  Deferred<br /><br />
		The product team has reviewed this issue and has deferred it for consideration at a later time.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


1
1
Sign in
to vote
ID 808207 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 11/10/2013 10:07:53 AM
Access Restriction Public

Description

The following C++ code compiled as x64 release (default settings) leads to MSVC2012/2013 C++ compiler crash (compiles well in debug and/or Win32 configurations).

struct NewLineNormalizer
{
  enum State { Begin, LF, CR, Combo };
  State state;

  explicit NewLineNormalizer(State st = Begin)
    : state(st) {}

  char* operator()(const char *from, const char *end, char *to)
  {
    char ch;
    switch (state)
    {
    case LF: goto LF_;
    case CR: goto CR_;
    case Combo: goto Combo_;
    default:; // Begin falls-through here
    }

    while (true)
    {
      ch = *from++;
      if (from == end)
        return state = Begin, to;
      if (ch == '\n') goto LF_;
      if (ch == '\r') goto CR_;
      *to++ = ch;
      continue;

    LF_: do
      {
        ch = *from++;
        if (ch == '\r') goto Combo_;
        *to++ = '\n';
        if (from == end)
          return state = LF, to;
      } while (ch == '\n');
      *to++ = ch;
      continue;

    CR_: do
      {
        ch = *from++;
        if (ch == '\n') goto Combo_;
        *to++ = '\n';
        if (from == end)
          return state = CR, to;
      } while (ch == '\r');
      *to++ = ch;
      continue;

    Combo_:
      ch = *from++;
      *to++ = '\n';
      if (from == end)
        return state = Combo, to;
      if (ch == '\n') goto LF_;
      if (ch == '\r') goto CR_;
      *to++ = ch;
    }
  }
};

There is no crash if while/do-while/continue are replaced with plain gotos.
Sign in to post a comment.
Posted by Microsoft on 11/14/2013 at 12:17 PM
Hi, thanks for the great repro case.

This is a bug in the compiler optimizer. We seem to be barfing trying to optimize the particularly gnarly control graph in your example. We'll address this in a future release.

It sounds like you already have the right workaround for this particular crash.

If this issue is severe, causing critical business situations or blocking your product development or deployment, please go to http://support.microsoft.com or call 1-800-MICROSOFT for assistance. For Microsoft premier customers, please contact your administrator, your Technical Account Manager, or your Microsoft premier account representative.

I am closing this MSConnect item. Feel free to respond if you need anything else.

Thanks!
Eric Brumer
Microsoft Visual C++ Team
Posted by Microsoft on 11/10/2013 at 11:16 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 11/10/2013 at 10:52 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)