[MC++] Internal Compiler Error with /Ox

M

Marcus Kwok

I am not sure if this is related to my previous thread
("NullReferenceException with value struct") so I am starting a new
thread.

I saw in
http://msdn.microsoft.com/library/d...cmex/html/vclrfrestrictionsofmanagedtypes.asp

they mention that value types cannot contain pointers to other managed
types. In my __value struct, I had an array of other __value objects,
so I changed it to an unmanaged array. Now, when I compile using /Ox
for full optimization, I get an Internal Compiler Error.

Can anybody propose a workaround? Upgrading to VS 2005 is not an option
at the time.


// Test.h
#pragma once

#using <mscorlib.dll>
#using <System.dll>
#using <System.Windows.Forms.dll>

namespace ICE
{
public __gc class Test : public System::Windows::Forms::Form
{
public:
Test(void) { }

static const int max_contours = 5;

__value struct Contours {
int num_contours;

__value struct ContourInfo {
double lower_bound;
int r;
int g;
int b;
} contours __nogc[max_contours];

//ContourInfo contours[];

//Contours()
// : contours(new ContourInfo[max_contours])
//{ }
};

protected:
void Dispose(System::Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispose(disposing);
}

private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container* components;

private:
bool is_blank(const Contours& contours)
{
Contours::ContourInfo empty = {0, 0, 0, 0};
bool blank = true;
for (int i = 0; i < contours.num_contours; ++i) {
if (!__box(contours.contours)->Equals(__box(empty))) {
blank = false;
}
}

return blank;
}
};
}


// Test.cpp
#include "Test.h"
#include <windows.h>

#using <mscorlib.dll>

int main()
{
ICE::Test* t = new ICE::Test;
}


Compile command:
cl /clr /Ox Test.cpp


Output:
Microsoft (R) C/C++ Optimizing Compiler Version 13.10.3077 for .NET Framework
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.

Test.cpp
c:\documents and settings\kwokmb1\my documents\work\code\test.h(61) : fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'f:\vs70builds\3077\vc\Compiler\Utc\src\p2\wvm\mdmiscw.c', line 754)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information


Note: The compiler file they list above does not exist on my system.
 
M

Marcus Kwok

Marcus Kwok said:
I saw in
http://msdn.microsoft.com/library/d...cmex/html/vclrfrestrictionsofmanagedtypes.asp

they mention that value types cannot contain pointers to other managed
types. In my __value struct, I had an array of other __value objects,
so I changed it to an unmanaged array. Now, when I compile using /Ox
for full optimization, I get an Internal Compiler Error.

It turns out that any of the optimization switches I tried resulted in
the ICE.
Can anybody propose a workaround? Upgrading to VS 2005 is not an option
at the time.

bool is_blank(const Contours& contours)
{
Contours::ContourInfo empty = {0, 0, 0, 0};
bool blank = true;
for (int i = 0; i < contours.num_contours; ++i) {
if (!__box(contours.contours)->Equals(__box(empty))) {
blank = false;
}
}

return blank;
}


I changed this to

bool is_blank(const Contours& contours)
{
bool blank = true;
for (int i = 0; i < contours.num_contours; ++i) {
if ((contours.contours.lower_bound != 0.0) ||
(contours.contours.r != 0) ||
(contours.contours.g != 0) ||
(contours.contours.b != 0)) {
blank = false;
}
}

return blank;
}

and I no longer get the ICE.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top