[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/default.asp?url=/library/en-us/vcmex/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[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\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.

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
.



Relevant Pages

  • Re: It Pays to Enrich Your C Skills
    ... Check if you can score a perfect 10 (without using a compiler). ... int main{ ... struct bitfield { ... out if it is a negative integer constant or a constant expression ...
    (comp.lang.c.moderated)
  • Re: Passing an already declarted array of structures!
    ... void LCD_PAINTSCREEN ... in above code by "int", ... If you guys see nothing wrong with the code, then I suppose its a compiler ... struct S { ...
    (microsoft.public.vc.language)
  • Re: Delay Routine: Fully-portable C89 if possible
    ... non-standard compiler with 8-bit shorts than a standard compiler with ... Embedded compilers sometimes support different sized types as extensions, beyond what is available through char, short int, int, long int and long long int. ... You mean padding the struct with extra elements, ... it avoids multiplies on lookups - multiplies can be costly on ...
    (comp.arch.embedded)
  • Re: void * vs char *
    ... cast p to a (struct s*) to avoid a compile-time error. ... struct s {int a;}; ... function call consists solely of an identifier, and if no declaration ... And see what your compiler has to say. ...
    (comp.lang.c)
  • Re: Linux 2.6.27.8
    ... struct pt_regs *regs); ... static int printbinary ... void show_regs ...
    (Linux-Kernel)