www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - Internal error: cgcod 2247

↑ ↓ ← Eduardo Nunes <Eduardo_member pathlink.com> writes:
Hi,

I have found a compiler error:
---(bug.cpp)----------------------------------
#include "stdio.h"

class A
{
const char *a;
unsigned int b;
public:
A() {a=NULL; b=(unsigned int)(-1);}
bool test(void) const {return b==(unsigned int)(-1);}
void foo(void) {b = 1;}
void bar(void) {printf("bar: %d\n",b);}
};

class B
{
A  a[2];
public:
A &get(int i)	{if(a[i].test())a[i].foo(); return a[i];}
};

int main(void)
{
B b;
b.get(0).bar();
return 0;
}
-----------------------------------------------
dmc -o+all bug.cpp
Internal error: cgcod 2247

Compiler version is 8.42n (beta)

Eduardo Nunes
Feb 14 2005
↑ ↓ → Ozaki <Ozaki_member pathlink.com> writes:
I tried your code, and found out the optimization of hlobal common
subexpressions elimination (cse) and dead assignment elimination (da) cause the
error. Disable anyone of two optimization mentioned (-o-cse or -o-cse) will
solve the problem. Hope this can help Walter to find the bug more easily.

In article <cur994$21m7$1 digitaldaemon.com>, Eduardo Nunes says...
Hi,

I have found a compiler error:
---(bug.cpp)----------------------------------
#include "stdio.h"

class A
{
const char *a;
unsigned int b;
public:
A() {a=NULL; b=(unsigned int)(-1);}
bool test(void) const {return b==(unsigned int)(-1);}
void foo(void) {b = 1;}
void bar(void) {printf("bar: %d\n",b);}
};

class B
{
A  a[2];
public:
A &get(int i)	{if(a[i].test())a[i].foo(); return a[i];}
};

int main(void)
{
B b;
b.get(0).bar();
return 0;
}
-----------------------------------------------
dmc -o+all bug.cpp
Internal error: cgcod 2247

Compiler version is 8.42n (beta)

Eduardo Nunes

Feb 14 2005