www.digitalmars.com         C & C++   DMDScript  

D - Internal error: ..\ztc\cgcod.c 1402

reply "Dario" <supdar yahoo.com> writes:
The following code causes this compiler output:
Internal error: ..\ztc\cgcod.c 1402

void subdivide()
{
    ColorVertex[] newdata;
    newdata.length = data.length * 4;

    for(uint i; i < data.length; i += 3)
    {
        newdata[i*4 + 0].mean ( data[i + 0] , data[i + 0] );
        newdata[i*4 + 1].mean ( data[i + 0] , data[i + 1] );
        newdata[i*4 + 2].mean ( data[i + 0] , data[i + 2] );

        newdata[i*4 + 3].mean ( data[i + 1] , data[i + 0] );
        newdata[i*4 + 4].mean ( data[i + 1] , data[i + 1] );
        newdata[i*4 + 5].mean ( data[i + 1] , data[i + 2] );

        newdata[i*4 + 6].mean ( data[i + 2] , data[i + 0] );
        newdata[i*4 + 7].mean ( data[i + 2] , data[i + 1] );
        newdata[i*4 + 8].mean ( data[i + 2] , data[i + 2] );

        newdata[i*4 + 9].mean ( data[i + 1] , data[i + 0] );
        newdata[i*4 +10].mean ( data[i + 2] , data[i + 1] );
        newdata[i*4 +11].mean ( data[i + 0] , data[i + 2] );
    }

    data = newdata; // olddata is now garbage
    glInterleavedArrays(GL_C3F_V3F, 0, data);
}

This is a rudimental function that subdivides some triangles (in a external
array) into smaller triangles (four for each one).
void ColorVertex.mean(ColorVertex, ColorVertex) is a method that computes
the color and the coords of the vertex which is between two two arguments.
I've appended the whole source. (GLFW is a OpenGL framework like GLUT).
I apologize if this error had been discussed already.   ='(
    Dario
Jun 23 2002
parent reply Burton Radons <loth users.sourceforge.net> writes:
Dario wrote:
 The following code causes this compiler output:
 Internal error: ..\ztc\cgcod.c 1402

[snip]
 void ColorVertex.mean(ColorVertex, ColorVertex) is a method that computes
 the color and the coords of the vertex which is between two two arguments.
 I've appended the whole source. (GLFW is a OpenGL framework like GLUT).
 I apologize if this error had been discussed already.   ='(

Passing a struct to a method or function causes this internal error. The only workaround I know of is that if you change ColorVertex.mean to take (ColorVertex *, ColorVertex *) instead; the error should disappear. It sure is a pain, hopefully Walter will be able to patch this bug up fairly soon after he returns.
Jun 23 2002
parent "Dario" <supdar yahoo.com> writes:
 Passing a struct to a method or function causes this internal error.
 The only workaround I know of is that if you change ColorVertex.mean to
 take (ColorVertex *, ColorVertex *) instead; the error should disappear.

 It sure is a pain, hopefully Walter will be able to patch this bug up
 fairly soon after he returns.

Thank you Burton!
Jun 24 2002