Thread overview
[Issue 1266] New: Cannot forward reference the typeof of the base type of a pointer whose base type is defined with typeof
Jun 15, 2007
d-bugmail
Jun 15, 2007
d-bugmail
Jun 15, 2007
d-bugmail
Jun 28, 2007
d-bugmail
Apr 18, 2009
d-bugmail
May 01, 2009
d-bugmail
May 15, 2009
Don
Mar 27, 2010
Rainer Schuetze
Feb 08, 2011
Walter Bright
Feb 08, 2011
Don
June 15, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1266

           Summary: Cannot forward reference the typeof of the base type of
                    a pointer whose base type is defined with typeof
           Product: D
           Version: 1.014
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic, rejects-valid
          Severity: normal
          Priority: P3
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: deewiant@gmail.com
OtherBugsDependingO 340
             nThis:


One of those hard to summarize legibly, yet relatively simple, bugs:

void f(typeof(*y) z) {}
typeof(x)* y;
int x;

Replace typeof(x) or typeof(*y) with int or move f after y and the code
compiles. As it is, it emits "Error: error: forward reference of typeof(x)"
without a line number for the error, in both DMD 1.014 and 1.015.


-- 

June 15, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1266





------- Comment #1 from deewiant@gmail.com  2007-06-15 11:11 -------
I was going to file this as a separate Bug, but it seems it's just a wonky error message for essentially the same thing:

void f(typeof(*y) z) {}
typeof(&x) y;
int x;

The above code errors out with the senseless "Error: can only * a pointer, not
a 'typeof(&x)'", but at least it comes with a line number pointing at the
typeof(*y), unlike the original code which used typeof(x)*.


-- 

June 15, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1266


deewiant@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |major
           Keywords|                            |ice-on-valid-code




------- Comment #2 from deewiant@gmail.com  2007-06-15 11:16 -------
Further testing:

f isn't needed, "typeof(*y) z;" is enough.

However, in the original ("typeof(x)* y;") case, using only "typeof(*y) z;"
without f causes a compiler crash (no error message). Hence I'm stepping up the
severity.


-- 

June 28, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1266





------- Comment #3 from bugzilla@digitalmars.com  2007-06-27 21:00 -------
At least it gives a line number now.


-- 

April 18, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1266





------- Comment #4 from clugdbug@yahoo.com.au  2009-04-18 17:45 -------
This seems to be fixed on DMD2.028 (although possibly because of some other patch I've made <g> -- that would indicate that it's a duplicate). Still segfaults on D1.042.


-- 

May 01, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1266





------- Comment #5 from bugzilla@digitalmars.com  2009-05-01 06:46 -------
I've fixed the seg fault in the upcoming 1.045 version, but the forward reference error remains.


-- 

May 15, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1266


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|diagnostic,                 |
                   |ice-on-valid-code           |
                 CC|                            |clugdbug@yahoo.com.au




--- Comment #6 from Don <clugdbug@yahoo.com.au>  2009-05-15 00:46:37 PDT ---
This is no longer an ICE, just one of the many rejects-valid forward reference issue.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 27, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=1266


Rainer Schuetze <r.sagitario@gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                 CC|                            |r.sagitario@gmx.de


--- Comment #7 from Rainer Schuetze <r.sagitario@gmx.de> 2010-03-27 06:05:49 PDT ---
Here's a patch, but I am not 100% sure, whether the scope is correct for the type aswell.

Index: expression.c ===================================================================
--- expression.c    (revision 421)
+++ expression.c    (working copy)
@@ -7432,6 +7432,7 @@
         error("can only * a pointer, not a '%s'", e1->type->toChars());
         return new ErrorExp();
     }
+    type = type->semantic(e1->loc, sc); // correct scope?
     rvalue();
     }
     return this;

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 08, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=1266


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WORKSFORME


--- Comment #8 from Walter Bright <bugzilla@digitalmars.com> 2011-02-07 22:11:53 PST ---
Compiles without error on 2.052 and 1.067

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 08, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=1266



--- Comment #9 from Don <clugdbug@yahoo.com.au> 2011-02-07 22:35:39 PST ---
Fix confirmed: this failed in 2.050 and 1.065 but is fixed in 2.051 and 1.066

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------