Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / May 2006

Tip: Looking for answers? Try searching our database.

[MC++] Internal Compiler Error with /Ox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marcus Kwok - 15 May 2006 18:51 GMT
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/vclr
frestrictionsofmanagedtypes.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.

Signature

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

Marcus Kwok - 16 May 2006 14:58 GMT
> I saw in
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmex/html/vclr
frestrictionsofmanagedtypes.asp

[quoted text clipped - 3 lines]
> 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.
[quoted text clipped - 11 lines]
>            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.

Signature

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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.