Bug 9538 – Regression (2.062): Can't use typeid on .ptr of static array

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-02-19T14:03:00Z
Last change time
2013-02-21T16:30:39Z
Keywords
pull
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2013-02-19T14:03:27Z
import std.stdio; void main() { void*[1] x; writeln(typeid(x.ptr)); } 2.061: $ dmd test.d > void** 2.062: $ dmd test.d > Error: void*[1u][0u] is not an lvalue
Comment #1 by puremagic — 2013-02-19T14:33:13Z
probably related: immutable(char)*[1] szSource = [source.toStringz()]; glCreateShaderProgramv(TYPE, 1, szSource.ptr); stopped working with dmd 2.062. it does not pass the correct string to openGL. and i still do not have my engine up running again, so these calls are probably not working as well: GLenum[] drawBuffers = [GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2]; check!glDrawBuffers(drawBuffers.length, drawBuffers.ptr);
Comment #2 by andrej.mitrovich — 2013-02-19T14:51:32Z
(In reply to comment #1) > probably related: > > immutable(char)*[1] szSource = [source.toStringz()]; > glCreateShaderProgramv(TYPE, 1, szSource.ptr); > > stopped working with dmd 2.062. > it does not pass the correct string to openGL. Might be related to http://d.puremagic.com/issues/show_bug.cgi?id=9539 However Issue 9539 is reproducible on 2.061 as well.
Comment #3 by k.hara.pg — 2013-02-21T02:25:07Z
(In reply to comment #2) > (In reply to comment #1) > > probably related: > > > > immutable(char)*[1] szSource = [source.toStringz()]; > > glCreateShaderProgramv(TYPE, 1, szSource.ptr); > > > > stopped working with dmd 2.062. > > it does not pass the correct string to openGL. > > Might be related to http://d.puremagic.com/issues/show_bug.cgi?id=9539 > > However Issue 9539 is reproducible on 2.061 as well. This is not related to bug 9539. https://github.com/D-Programming-Language/dmd/pull/1681
Comment #4 by code — 2013-02-21T11:05:52Z
(In reply to comment #0) > 2.061: > $ dmd test.d > > void** I still get an error for 2.061 and 2.060. Error: type void*[1LU] is not an expression The error message has changed with https://github.com/D-Programming-Language/dmd/pull/1382 to Error: void*[1u][0u] is not an lvalue. I've reduced the importance to normal.
Comment #5 by github-bugzilla — 2013-02-21T11:10:20Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/7c6a268b7eb9b7901e06aabdfb6aefc8a4017e5f fix Issue 9538 - Regression (2.062): Can't use typeid on .ptr of static array https://github.com/D-Programming-Language/dmd/commit/ba822749d2cc15ed984215eba10bd6638eeda326 Merge pull request #1681 from 9rnsr/fix9538 Issue 9538 - Regression (2.062): Can't use typeid on .ptr of static array
Comment #6 by andrej.mitrovich — 2013-02-21T11:14:08Z
(In reply to comment #4) > (In reply to comment #0) > > 2.061: > > $ dmd test.d > > > void** > > I still get an error for 2.061 and 2.060. > Error: type void*[1LU] is not an expression You must be testing it wrong, I don't get either of these errors in 2.060 and 2.061. Make sure you're calling the right DMD and if using RDMD to use --force.
Comment #7 by k.hara.pg — 2013-02-21T16:30:39Z
(In reply to comment #4) > (In reply to comment #0) > > 2.061: > > $ dmd test.d > > > void** > > I still get an error for 2.061 and 2.060. > Error: type void*[1LU] is not an expression > > The error message has changed with > https://github.com/D-Programming-Language/dmd/pull/1382 to > Error: void*[1u][0u] is not an lvalue. > > I've reduced the importance to normal. This is actually regression. It was introduced by fixing bug 8913. Before fixing 8913, following wrong expression had allowed. alias X = int[1]; pragma(msg, typeof(X.ptr)); // printed int* auto p = X.ptr; // compiled with -o- switch After that, it correctly be rejected in compilation phase (currently it shows some poor error message, and I think we should improve it), but it had take out another hidden problem in TypeQualified::resolveHelper. The typeid operand "x.ptr" is *parsed* as a type, then resolved in TypeIdn\entifier::resolve to the actual expression. But, the process in resolveHelper had a bug that rewrites x.ptr to typeof(x).ptr. The 'ptr' property for array type should be treated as like as built-in stringof and mangleof property, but wasn't. Finally I chose refactoring resolveHelper to fix this regression. During it, I found another bug 9554, and they are fixed together in the pull #1681.