www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - -inline compiler bug

reply nail <nail_member pathlink.com> writes:
Hi all.

I found one more bug. Sorry for the big snipet, I simplified it as I could:

module test;
import std.math;

struct Vector3
{
align(1)
{
float x = 0;
float y = 0;
float z = 0;
}


static Vector3 opCall(float x, float y, float z)
{
Vector3 v;
v.set(x, y, z);
return v;
}

void set(float x, float y, float z)
{
this.x = x;
this.y = y;
this.z = z;
}
}

struct Matrix33
{
private:
align (1) union
{
struct
{
float m00, m01, m02;
float m10, m11, m12;
float m20, m21, m22;			
}

float m[3][3];
Vector3 v[3];
}

public:
Matrix33 opCall(float m00, float m01, float m02,
float m10, float m11, float m12,
float m20, float m21, float m22)
{
Matrix33 mat;
mat.m00 = m00;		mat.m01 = m01;		mat.m02 = m02;
mat.m10 = m10;		mat.m11 = m11;		mat.m12 = m12;
mat.m20 = m20;		mat.m21 = m21;		mat.m22 = m22;
return mat;
}

static Matrix33 rotationX(float radians)
{
Matrix33 mat;
float c = cos(radians);
float s = sin(radians);
with (mat)
{
v[0] = Vector3(1, 0, 0);
v[1] = Vector3(0, c, s);
v[2] = Vector3(0,-s, c);
}

return mat;
}

static Matrix33 rotationY(float radians)
{
Matrix33 mat;
float c = cos(radians);
float s = sin(radians);
with (mat)
{
v[0] = Vector3(c, 0,-s);
v[1] = Vector3(0, 1, 0);
v[2] = Vector3(s, 0, c);
}

return mat;
}

static Matrix33 rotationZ(float radians)
{
Matrix33 mat;
float c = cos(radians);
float s = sin(radians);
with (mat)
{
v[0] = Vector3( c, s, 0);
v[1] = Vector3(-s, c, 0);
v[2] = Vector3( 0, 0, 1);
}

return mat;
}

static Matrix33 rotation(float yaw, float pitch, float roll)
{
return Matrix33.rotationZ(roll) * Matrix33.rotationX(pitch) *
Matrix33.rotationY(yaw);
}

Matrix33 opMul(Matrix33 mat)
{
return Matrix33(m00 * mat.m00 + m01 * mat.m10 + m02 * mat.m20,
m00 * mat.m01 + m01 * mat.m11 + m02 * mat.m21,
m00 * mat.m02 + m01 * mat.m12 + m02 * mat.m22,
m10 * mat.m00 + m11 * mat.m10 + m12 * mat.m20,
m10 * mat.m01 + m11 * mat.m11 + m12 * mat.m21,
m10 * mat.m02 + m11 * mat.m12 + m12 * mat.m22,
m20 * mat.m00 + m21 * mat.m10 + m22 * mat.m20,
m20 * mat.m01 + m21 * mat.m11 + m22 * mat.m21,
m20 * mat.m02 + m21 * mat.m12 + m22 * mat.m22 );
}
}

int main ( char [] [] args )
{
return 0;	
}

This code does not compile with -inline compiler flag:
C:/dmd/bin/dmd -Isrc -O -inline -release -c
-ofbuild\examples\test-win32-release\test.obj examples\src\test\test.d
examples\src\test\test.d(149): rotationZ(roll) is not an lvalue

And does without it. The hotspot is in construction
with (mat)
{
v[0] = Vector3( c, s, 0);
v[1] = Vector3(-s, c, 0);
v[2] = Vector3( 0, 0, 1);
}

Once I comment it out all compiles fine.

PS: One more question - I already found at least 3 compiler bugs, no one was
fixed. Does they considered at all? Or only phobos bugs corrected, Walter?
Feb 06 2005
next sibling parent reply zwang <nehzgnaw gmail.com> writes:
I'm pretty sure Walter is actively fighting with compiler bugs.
I just got an email from him today that a crashing bug reported
last week has been fixed.

nail wrote:
 PS: One more question - I already found at least 3 compiler bugs, no one was
 fixed. Does they considered at all? Or only phobos bugs corrected, Walter?
 
 
Feb 06 2005
parent nail <nail_member pathlink.com> writes:
In article <cu5ieo$1e6f$1 digitaldaemon.com>, zwang says...
I'm pretty sure Walter is actively fighting with compiler bugs.
I just got an email from him today that a crashing bug reported
last week has been fixed.

nail wrote:
 PS: One more question - I already found at least 3 compiler bugs, no one was
 fixed. Does they considered at all? Or only phobos bugs corrected, Walter?
 
 
Maybe mine are simply forgotten? This bug, bug with nested class private members are not accessible from one module, and static TypeInfo[] in template class isn't linkable
Feb 06 2005
prev sibling next sibling parent reply =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
nail wrote:

 I found one more bug. Sorry for the big snipet, I simplified it as I could:
 This code does not compile with -inline compiler flag:
The code compiles OK with the GDC compiler. (Didn't test if it actually worked, though, since there was no unittest present for it) --anders
Feb 06 2005
parent reply nail <nail_member pathlink.com> writes:
In article <cu5oea$1iu2$2 digitaldaemon.com>,
=?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= says...
nail wrote:

 I found one more bug. Sorry for the big snipet, I simplified it as I could:
 This code does not compile with -inline compiler flag:
The code compiles OK with the GDC compiler. (Didn't test if it actually worked, though, since there was no unittest present for it) --anders
Hm... But what is the difference between unittests present or not? There are no unittests in the example and even option that enables it, i.e. code compiled under win32 with -inline -release and -O options
Feb 06 2005
parent =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
nail wrote:

 Hm... But what is the difference between unittests present or not? There are no
 unittests in the example and even option that enables it, i.e. code compiled
 under win32 with -inline -release and -O options
I meant that it compiled without warnings, even when using -inline, but I didn't run it to verify that it actually worked or anything :-) --anders
Feb 06 2005
prev sibling parent Thomas Kuehne <thomas-dloop kuehne.THISISSPAM.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

nail wrote:
| Hi all.
|
| I found one more bug. Sorry for the big snipet, I simplified it as I
could:
|
| module test;
| import std.math;
|
| struct Vector3
| {
| align(1)
| {
| float x = 0;
| float y = 0;
| float z = 0;
| }
|
|
| static Vector3 opCall(float x, float y, float z)
| {
| Vector3 v;
| v.set(x, y, z);
| return v;
| }
|
| void set(float x, float y, float z)
| {
| this.x = x;
| this.y = y;
| this.z = z;
| }
| }
|
| struct Matrix33
| {
| private:
| align (1) union
| {
| struct
| {
| float m00, m01, m02;
| float m10, m11, m12;
| float m20, m21, m22;			
| }
|
| float m[3][3];
| Vector3 v[3];
| }
|
| public:
| Matrix33 opCall(float m00, float m01, float m02,
| float m10, float m11, float m12,
| float m20, float m21, float m22)
| {
| Matrix33 mat;
| mat.m00 = m00;		mat.m01 = m01;		mat.m02 = m02;
| mat.m10 = m10;		mat.m11 = m11;		mat.m12 = m12;
| mat.m20 = m20;		mat.m21 = m21;		mat.m22 = m22;
| return mat;
| }
|
| static Matrix33 rotationX(float radians)
| {
| Matrix33 mat;
| float c = cos(radians);
| float s = sin(radians);
| with (mat)
| {
| v[0] = Vector3(1, 0, 0);
| v[1] = Vector3(0, c, s);
| v[2] = Vector3(0,-s, c);
| }
|
| return mat;
| }
|
| static Matrix33 rotationY(float radians)
| {
| Matrix33 mat;
| float c = cos(radians);
| float s = sin(radians);
| with (mat)
| {
| v[0] = Vector3(c, 0,-s);
| v[1] = Vector3(0, 1, 0);
| v[2] = Vector3(s, 0, c);
| }
|
| return mat;
| }
|
| static Matrix33 rotationZ(float radians)
| {
| Matrix33 mat;
| float c = cos(radians);
| float s = sin(radians);
| with (mat)
| {
| v[0] = Vector3( c, s, 0);
| v[1] = Vector3(-s, c, 0);
| v[2] = Vector3( 0, 0, 1);
| }
|
| return mat;
| }
|
| static Matrix33 rotation(float yaw, float pitch, float roll)
| {
| return Matrix33.rotationZ(roll) * Matrix33.rotationX(pitch) *
| Matrix33.rotationY(yaw);
| }
|
| Matrix33 opMul(Matrix33 mat)
| {
| return Matrix33(m00 * mat.m00 + m01 * mat.m10 + m02 * mat.m20,
| m00 * mat.m01 + m01 * mat.m11 + m02 * mat.m21,
| m00 * mat.m02 + m01 * mat.m12 + m02 * mat.m22,
| m10 * mat.m00 + m11 * mat.m10 + m12 * mat.m20,
| m10 * mat.m01 + m11 * mat.m11 + m12 * mat.m21,
| m10 * mat.m02 + m11 * mat.m12 + m12 * mat.m22,
| m20 * mat.m00 + m21 * mat.m10 + m22 * mat.m20,
| m20 * mat.m01 + m21 * mat.m11 + m22 * mat.m21,
| m20 * mat.m02 + m21 * mat.m12 + m22 * mat.m22 );
| }
| }
|
| int main ( char [] [] args )
| {
| return 0;	
| }
|
| This code does not compile with -inline compiler flag:
| C:/dmd/bin/dmd -Isrc -O -inline -release -c
| -ofbuild\examples\test-win32-release\test.obj examples\src\test\test.d
| examples\src\test\test.d(149): rotationZ(roll) is not an lvalue
|
| And does without it. The hotspot is in construction
| with (mat)
| {
| v[0] = Vector3( c, s, 0);
| v[1] = Vector3(-s, c, 0);
| v[2] = Vector3( 0, 0, 1);
| }
|
| Once I comment it out all compiles fine.

Next time please cut it down properly and post it to the bugs
newsgroup (digitalmars.D.bugs).

Otherwise I am going to charge for cuting the sample code - or will
simply ignore it.

Added to DStress as:
http://dstress.kuehne.cn/compile/inline_02.d
http://dstress.kuehne.cn/compile/inline_03.d

Note: this seems to be a DMD-only bug

Thomas


-----BEGIN PGP SIGNATURE-----

iD8DBQFCB3E83w+/yD4P9tIRAmvPAJ9X46PMSgklLIiogy3dkR9x45PNVACfYekc
q/Er4g1UZIFRK0+j8eusbf4=
=gK4L
-----END PGP SIGNATURE-----
Feb 07 2005