www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1266] New: Cannot forward reference the typeof of the base type of a pointer whose base type is defined with typeof

reply d-bugmail puremagic.com writes:
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.


-- 
Jun 15 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1266






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)*.


-- 
Jun 15 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
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





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.


-- 
Jun 15 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1266






At least it gives a line number now.


-- 
Jun 27 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1266






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.


-- 
Apr 18 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1266






I've fixed the seg fault in the upcoming 1.045 version, but the forward
reference error remains.


-- 
May 01 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
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





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: -------
May 15 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Mar 27 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1266


Walter Bright <bugzilla digitalmars.com> changed:

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



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: -------
Feb 07 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1266




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: -------
Feb 07 2011