470,810 Members | 964 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,810 developers. It's quick & easy.

[MC++] Internal Compiler Error with /Ox

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/de...nagedtypes.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[i])->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\mdm iscw.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.

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
May 15 '06 #1
1 1424
Marcus Kwok <ri******@gehennom.invalid> wrote:
I saw in
http://msdn.microsoft.com/library/de...nagedtypes.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[i])->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[i].lower_bound != 0.0) ||
(contours.contours[i].r != 0) ||
(contours.contours[i].g != 0) ||
(contours.contours[i].b != 0)) {
blank = false;
}
}

return blank;
}

and I no longer get the ICE.

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
May 16 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Ayende Rahien | last post: by
4 posts views Thread by David Sworder | last post: by
1 post views Thread by mahesh | last post: by
8 posts views Thread by WebSnozz | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.